The static keyword java

static method:

1. Definition:

"Java programming ideas" is mentioned: static method is not this way, the internal static methods can not call non-static method, in turn, is possible, and can be created in the absence of any object, only to call the class by itself use static method, which in fact is the static method

 

2: Concept:

static methods are generally known as static methods, because the static method does not depend on the object can be accessed, so there is no this, and modified static methods can not call non-static member variables and non-static member methods, but non-static member can call a static method member method

 

static variables:

definition:

static variables are also referred to as static variables, the difference between static variables and non-static variables: Static variables are shared by all objects, there is only one copy in memory, loaded at the class initialization, rather than static variables are subject-specific, in when creating an object is initialized, there are multiple copies of each object has a copy independently of each other

 

static code block:

There static keyword is a more critical role for forming a static block of code to optimize the application performance. static blocks may be placed anywhere in the class, the class may have a plurality of static blocks. When the class is loaded for the first time, each of the static block may be performed in the order of static blocks, and only once.

 

 

Guess you like

Origin www.cnblogs.com/wgblog-code/p/11206354.html