Comparing a string created from a char[]
<p>My code compares the equality between two words. It prints a value "TRUE" if the strings are equal. Else it returns false. Java "equals" function is being used</p>

<pre><code>class k{  

    public static void main(String args[]){  
        String s1="Sach";  
        String s2=word();  
        String s3=new String("Sach");   
        System.out.println(s1.equals(s2));  
        System.out.println(s1.equals(s3));      
    } 

    public static String word() {
        char[] str=new char[100];
        str[0]='S';
        str[1]='a';
        str[2]='c';
        str[3]='h';
        String ss=new String(str);
        System.out.println(ss);
        return ss;
    }
} 
</code></pre>

<p>I need to fetch some selected alphabets into an array and convert it to string. After this conversion, the function returns the string. But comparison results in an incorrect value. Is there some other method to convert the array to string so that this program gives a correct result.</p>