+ 10
Can someone please explain the word static
4 Answers
+ 8
@Uvaish thanks
+ 3
The value of a static variable is stored in the class itself rather than in a particular instance of a class (object). That is, if you create two class objects with static variable, the value of the static variable for each object class will be the same anyway
https://code.sololearn.com/c0OMpUUlGHJg/?ref=app
0
how can u determine what this means public class Program
{
public static void main(String[] args) {
mclass c1 = new mclass();
mclass c2 = new mclass();
c1.x = 5;
System.out.println(c1.x); //Static variable of class mclass
System.out.println(c2.x); // Static variable of class mclass
c2.x = 41;
System.out.println(c2.x);
System.out.println(c1.x);
}
}
public class mclass{
static int x;
}