Tuesday, 29 September 2015

Java Program to Comparing two strings using == Operator

/**
 *
 */

/**
 *
 *
 */
public class Stringcmp {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s1 = new String("Test");
String s2 = "Test";
if(s1==s2)
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}

output:-
Not Equal

No comments:

Post a Comment