23 static keyword

Static variables : When adding static in front of a class member variable indicates that variable belongs to the class of all , no matter how many objects out of the new, this variable should be the name of the class variable name. Access;

 

Static methods :

public static void eat(){
    ..........        
}

 

Static methods can not call non-static member variables, can only call static variables .

Guess you like

Origin www.cnblogs.com/CPU-Easy/p/12153321.html