public class StringExample1 {
//Difference between "String Literal" and "String Object"
public static void main (String args[])
{
String str1 = "Java";
String str2 = "Java";
System.out.println("Is str1==str2 ? " +( str1==str2)); //Prints true
String str3 = new String("Java");
System.out.println("Is str1==str3 ? " +( str1==str3)); //Prints false
}
}
No comments:
Post a Comment