Thursday, October 13, 2005

What is the output of the following code?

public class StringExample{

public static void main(String []args){
String s="New";
String s1=s;
String s2="D";
String s3="New";

System.out.println(s==s1);
System.out.println(s3==s2);
System.out.println(s3==s1);

System.out.println(s1.equals(s1));
System.out.println(s3.equals(s2));
System.out.println(s3.equals(s1));

}
}

Ans :

true
false
true

true
false
true

0 Comments:

Post a Comment

<< Home