title: Creating my own String class / substring method
body: <p>I am working on an exercise that consists of creating my own implementation of the String class, with some of the methods that exist in this class. I am having some trouble with creating a working method for returning a substring. So far my class implementation looks like this:</p>
  
  <pre><code>public class MyString2 {
  
      private String s;
  
      public MyString2(String s) {
          this.s = s;
      }
  
      public MyString2 substring(int begin) {
  
          String substring = "";
  
          for (int i = begin; i &lt; s.length(); i++) {
              substring += s.charAt(i);
          }
          return new MyString2(substring);
      }
  
  }
  </code></pre>
  
  <p>The idea behind the method is pretty simple;</p>
  
  <p>Create a blank substring, and then concat each character from the input string beginning from a chosen index. Below is the main method for testing the class:</p>
  
  <pre><code>public static void main(String[] args) {
  
          MyString2 s1 = new MyString2("string");     
          MyString2 substring = s1.substring(3);
  
          System.out.println(substring);
  
      }
  </code></pre>
  
  <p>The program returns <em>ch10.MyString2@2a139a55</em>, can anyone please tell me what is wrong with my procedure?</p>