java - day014 - compile, run

  • Compile
    • Static member
    • Private variables
    • Member variables
  • Runtime
    • Non-static method
  • Package day1401; 
    
    public  class Test1 {
         public  static  void main (String [] args) { 
    
            B B = new new B (); 
            A A = new new B (); 
            
            // operation period, and is bound to the subclass method 
            BP (); 
            AP (); 
            
            // compile lookup
             // compile, based on the type of a variable defined 
             // Find f in this class () method and bind 
            
            Bf (); 
            of Af (); 
            
            / * 
             * compile-bound 
             * 
             * / 
            System.out.println (b.v1); 
            System.out.println (a.v1); 
        } 
    }
    
    
    class A{
        
        int v1 = 2;
        static void f() {
            System.out.println("A.f()");
        }
        
        void p() {
            System.out.println("A.p()");
        }
        
    }
    
    
    class B extends A {
        int v1 = 1;
        static void f() {
            System.out.println("B.f()");
        }
        
        void p() {
            System.out.println("B.p()");
        }
            
    }

     

Guess you like

Origin www.cnblogs.com/dingzhijie/p/11210737.html