1. 

 1 class Some {
 2     static{
 3         System.out.println("1");
 4     }
 5     
 6     public Some(){
 7         System.out.println("2");
 8     }
 9 }
10 
11 class Some2 extends Some{
12     static{
13         System.out.println("a");
14     }
15     
16     public Some2(){
17         System.out.println("b");
18     }
19 }

2.

    public static void main(String[] args) throws Exception {
        
//        new Some2();   //1a2b
        
//        new Some(); new Some2();  12a2b
        
//        Class.forName("com.gl.typeof.Some2");  //1a
        
//        Class.forName("com.gl.typeof.Some2"); new Some2(); // 1a2b   
//        Class.forName("com.gl.typeof.Some2").newInstance(); //1a2b 
    }

 

相关文章:

  • 2021-10-31
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
  • 2021-12-12
  • 2021-10-16
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2022-01-06
  • 2021-12-04
  • 2021-06-21
  • 2021-12-20
  • 2021-10-25
  • 2021-11-03
  • 2021-08-01
相关资源
相似解决方案