Understanding explicit cast for String producing different results in c# and Java
<p>I wrote a same(..similar?) piece of code for Java 7 and C#(.net 3.5) and got a confusing output. Please help me in understanding this behavior:</p>

<p>Java:</p>

<pre><code>public class strTest {
    public static void main(String [] s) {      
        String s1 = "abc";
        String s2 = new String(new char[] {'a', 'b', 'c'});
        System.out.println(s1 == s2);                      // false
        System.out.println(((Object)s1) == ((Object)s2));  // false
        System.out.println(s1.equals(s2));                 // true
    }
}
</code></pre>

<p>Output : false
false
true</p>

<p>C#:</p>

<pre><code>namespace ConsoleApplication1
{
    class Program2
    {
        static void Main(string[] args)
        {
            String s1 = "abc";
            String s2 = new String(new Char[] {'a', 'b', 'c'});
            Console.WriteLine(s1 == s2);                     // true
            Console.WriteLine(((Object)s1) == ((Object)s2)); // false
            Console.WriteLine(s1.Equals(s2));                // true
        }
    }
}
</code></pre>

<p>Output : True
False
True</p>

<p>I am aware of concepts like String immutability and String pool but I guess I am missing the finer print. </p>

<p>In java: Why did it create a new String object for s2 when it could have used the one which is referenced by s1? Isn't that what String pool is supposed to achieve?</p>
