can anyone please explain the output of the program given below:
class A123
{
public static void main(
String args[])
{
String s1="hello123";
String s2="hello"+String.valueOf(123);
String s3="hello"+"123";
String s5=new String("hello123");
if(s1==s2)
System.out.println("s1==s2");
if(s1==s3)
System.out.println("s1==s3");
if(s1==s5)
System.out.println("s1==s5");
if(s2==s3)
System.out.println("s2==s3");
if(s2==s5)
System.out.println("s2==s5");
if(s3==s5)
System.out.println("s3==s5");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s5);
}
}
why s1 is eaqual to s3 and not s2