标签:mil important closed 检验 log 集合 分享 bre 语句
1 class StringTest{ 2 StringTest(){ 3 s3 = "4567"; 4 } 5 6 String s1; 7 String s2 = "1234"; 8 String s3; 9 } 10 11 public class MainTest { 12 public static void main(String[] args) { 13 StringTest st = new StringTest(); 14 System.out.println(st.s1); 15 System.out.println(st.s2); 16 System.out.println(st.s3); 17 } 18 }
1 class Test{ 2 Test(){ 3 System.out.println("Test"); 4 } 5 6 Test(String s){ 7 System.out.println(s+"test"); 8 } 9 } 10 11 public class MainTest { 12 public static void main(String[] args) { 13 Test t = new Test(); 14 Test t2 = new Test("1234"); 15 } 16 }
1 class Dog{ 2 Dog(int i){ 3 System.out.println("barking"); 4 } 5 6 Dog(double d){ 7 System.out.println("howling"); 8 } 9 10 Dog(char c){ 11 System.out.println("Meow~"); 12 } 13 14 Dog(int i, boolean b){ 15 System.out.println("I B"); 16 } 17 18 Dog(boolean b, int i){ 19 System.out.println("B I"); 20 } 21 } 22 23 public class MainTest { 24 public static void main(String[] args) { 25 Dog d1 = new Dog(1); 26 Dog d2 = new Dog(1.5); 27 Dog d3 = new Dog(‘c‘); 28 29 Dog bi1 = new Dog(1,true); 30 Dog bi2 = new Dog(true,1); 31 } 32 }
1 class Test{ 2 int i; 3 double d; 4 } 5 6 public class MainTest { 7 public static void main(String[] args) { 8 Test t = new Test(); 9 System.out.println(t.i); 10 System.out.println(t.d); 11 } 12 }
1 class Test{ 2 void method1(){ 3 method2(); 4 this.method2(); 5 } 6 7 void method2(){ System.out.println("Ah,be called!!"); } 8 } 9 10 public class MainTest { 11 public static void main(String[] args) { 12 Test t = new Test(); 13 t.method1(); 14 } 15 }
1 class Test{ 2 Test(String s, double i){ 3 this(i); 4 ss = s; 5 6 System.out.println("name: "+ss); 7 System.out.println("Area: "+ii); 8 } 9 10 Test(double i){ 11 ii = i*i*3.14; 12 } 13 14 String ss; 15 double ii; 16 } 17 18 public class MainTest { 19 public static void main(String[] args) { 20 Test t = new Test("Circle",2); 21 } 22 }
1 class Test{ 2 protected void finalize(){ 3 //super.finalize(); 4 System.out.println("Ah!!NO!!!"); 5 } 6 } 7 8 public class MainTest { 9 public static void main(String[] args) { 10 Test t = new Test(); 11 System.gc(); 12 } 13 }
1 class Tank{ 2 protected void finalize(){ 3 //super.finalize(); 4 if(isFull){ 5 System.out.println("Not Good"); 6 } 7 else{ 8 System.out.println("Good!"); 9 } 10 } 11 12 boolean isFull = false; 13 } 14 15 public class MainTest { 16 public static void main(String[] args) { 17 Tank t = new Tank(); 18 System.gc(); 19 } 20 }
1 class Test{ 2 static String s1 = "1234"; 3 static String s2; 4 static{ 5 s2 = "4567"; 6 } 7 8 static void func(){ 9 System.out.println(Test.s1); 10 System.out.println(Test.s2); 11 } 12 } 13 14 public class MainTest { 15 public static void main(String[] args) { 16 Test.func(); 17 } 18 }
1 class Test{ 2 String s1; 3 { 4 s1 = new String("1234"); 5 } 6 }
1 public class MainTest { 2 public static void main(String[] args) { 3 String[] arrayString = {"1111","2222","3333","4444"}; 4 for(String s:arrayString) 5 { 6 System.out.println(s); 7 } 8 } 9 }
1 class Test{ 2 Test(String s){ 3 System.out.println(s); 4 } 5 } 6 7 public class MainTest { 8 public static void main(String[] args) { 9 Test[] arrayTest = new Test[]{ 10 new Test("123"), 11 new Test("456") 12 }; 13 } 14 }
1 class Test{ 2 Test(String... s){ 3 } 4 } 5 6 public class MainTest { 7 public static void main(String[] args) { 8 Test t1 = new Test("111","222"); 9 Test t2 = new Test(new String[]{"333","444"}); 10 } 11 }
1 public class MainTest { 2 public static void main(String... args) { 3 for(String s:args) 4 { 5 System.out.println(s); 6 } 7 } 8 }
1 enum CNY{ 2 CNY1,CNY5,CNY10,CNY20,CNY50,CNY100; 3 } 4 5 public class MainTest { 6 public static void main(String[] args) { 7 for (CNY temp : CNY.values()) { 8 System.out.println(temp + " " + temp.ordinal()); 9 } 10 11 CNY cnyTemp = CNY.CNY5; 12 switch (cnyTemp){ 13 case CNY1: 14 System.out.println("1 Yuan"); 15 break; 16 17 case CNY5: 18 System.out.println("5 Yuan"); 19 break; 20 21 case CNY10: 22 System.out.println("10 Yuan"); 23 break; 24 25 case CNY20: 26 System.out.println("20 Yuan"); 27 break; 28 29 case CNY50: 30 System.out.println("50 Yuan"); 31 break; 32 33 case CNY100: 34 System.out.println("100 Yuan"); 35 break; 36 37 default: 38 System.out.println("Error : Fake Money"); 39 } 40 } 41 }
标签:mil important closed 检验 log 集合 分享 bre 语句
原文地址:http://www.cnblogs.com/tutut/p/7228402.html