0
Any good meaning of static and its uses?
2 Antworten
+ 2
static is a keyword in java which specifies that the member of a class (the member being declared static) is a single copy for all instances of a class. Like normal members, it is not made into separate copies for separate objects of a class.
example code
class A{
static int num = 0;
}
class B{
A h1 = new A();
A h2 = new A();
public static void main (String[] args){
h1.num += 1;
h2.num += 1;
System.out.println(h1.a);
// will print 2
}
}