java static methods and static fields

public  class Dog {
     public  static  void main (String [] args) { 
        A A = new new A (); 
        a.add (); // Java static methods and instance objects can access the class static field, C #, but does not; 
        int ID = a.id; 
        System.out.println (ID); 
    } 
} 
class A {
     public  static  int ID = 10 ;
     public  static  void the Add () { 
        System.out.println (ID); 
    } 
}

 

Guess you like

Origin www.cnblogs.com/mlh1421/p/11331640.html