Java basic problem
<p>i was working on the basic java program and i found verry funny thing which i am sharing with you. foo() gives output (s==s1) = false and bar gives (s==s1) = true.</p>

<p>I want to know why this happens.</p>

<pre><code>public class StringTest
{
  public static void main(String[] args){
    foo();
    bar();
  }
  public static void foo(){
    String s = "str4";
    String s1 = "str" + s.length();
    System.out.println("(s==s1) = " + (s1==s));
  }
  public static void bar(){
    String s = "str4";
    String s1 = "str" + "4";
    System.out.println("(s==s1) = " + (s1==s));
 }
}
</code></pre>
