标签:code str1 pre out als str extend end style
1 public class HelloA { 2 public HelloA() { 3 System.out.println("HelloA"); 4 } 5 6 { 7 System.out.println("lam A class"); 8 } 9 static { 10 System.out.println("static A"); 11 } 12 13 }
1 public class HelloB extends HelloA { 2 public HelloB() { 3 System.out.println("HelloB"); 4 } 5 6 { 7 System.out.println("lam B class"); 8 } 9 static { 10 System.out.println("static B"); 11 } 12 13 public static void main(String[] args) { 14 new HelloB(); 15 } 16 }
执行结果:
1 static A 2 static B 3 lam A class 4 HelloA 5 lam B class 6 HelloB
1 public class Test { 2 public static void main(String[] args) { 3 String str1 = "Hello"; 4 String str2 = "He" + new String("llo"); 5 System.out.println(str1 == str2); 6 str2 = "He" + "llo"; 7 System.out.println(str1 == str2); 8 } 9 }
比较结果:
false
true
标签:code str1 pre out als str extend end style
原文地址:http://www.cnblogs.com/qq634571685/p/7125791.html