class TestStringMethods {

    public static void main(String[] args) {

        // these all return EQUAL; no new string created    
        // original string reference is returned by the methods
        if("String".substring(0) == "String") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");       
    
        if("String".substring(0,6) == "String") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");

        if("String".replace('t','t') == "String") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");
            
        if("String".trim() == "String") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");
            

        // these return NOT EQUAL as new objects are created
        // ie the result of the method was different from the
        // original string

        if("String".substring(0,4) == "Stri") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");

        if("String".replace('t','T') == "STring") 
            System.out.println("Equal"); 
        else 
            System.out.println("Not Equal");
    
    
    }

}