Java Puzzle–Immutable String

what will be output of the following program ?

  1: class StringTest2 
  2: {
  3: 	public static void main(String[] args) 
  4: 	{
  5: 		String str1 = "Hello";
  6: 		String str2 = "HELLO";
  7: 		String str3 = str1.toUpperCase();
  8: 		String str4 = str2.toUpperCase();
  9: 		System.out.println(str1 == str3);
 10: 		System.out.println(str2 == str4);
 11: 	}
 12: }

Comments

Post a Comment

Popular posts from this blog

State Design Pattern by Example

Eclipse command framework core expression: Property tester

Composite Design Pattern by example