0
variables
why sometimes we should put public static in case of declaring variables in java?
1 Antwort
0
*Public and access modifiers in general:
One of the main principle of OOP is 'information hiding', which means that objects don't reveal all of their details to the outside world. Java has access modifiers to restrict access to members of classes, traits, objects and packages. Access Modifiers control how much of an object is visible to the rest of Java program, and packages provide the highest level of control over object visibility. More about access modifiers : http://net-informations.com/java/basics/modifiers.htm
*Static:
static members belong to the class instead of a specific instance.
It means that only one instance of a static field exists even if you create a million instances of the class or you don't create any. It will be shared by all instances.