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:
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 < s.length(); i++) {
            substring += s.charAt(i);
        }
        return new MyString2(substring);
    }
}
The idea behind the method is pretty simple;
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:
public static void main(String[] args) {
        MyString2 s1 = new MyString2("string");     
        MyString2 substring = s1.substring(3);
        System.out.println(substring);
    }
The program returns ch10.MyString2@2a139a55, can anyone please tell me what is wrong with my procedure?
 
    