Static keyword:
We all know the static modifier, which means that the corresponding variable or method is common to an instance of this class, and it is not necessary to create an instance of the class to access it.
eg. public static final Double PI = 3.14 ... Can be obtained directly through Math.PI.
Front of all good understanding,static method always some do not understand, the following focus on learning static Mathod:
The Static methods is methods that does not the operate on objects. For example, Math.pow (A, b) is called on the Math class, not Object.
you can think of static methods as methods that don ' t has a this parameter. in a nonstatic method, the this parameter refers To The implicit parameter of the method.
a static method can access a static feld. But cannot access the fields of the instance.
use static methods in both situations:
? When a method doesn ' t need to access the object state because all needed parameters is supplied as explicit para Meters (example: math.pow).
? When a method is only needs to access static Felds of the Class (example: employee.getnextid).
Factory Method:
Core Java I Reading notes