0
I did not exactly get about this (public static void).?
7 Antworten
+ 3
public: It's accessible outside the class
static: It's shared across all instances and the class
void: Does not return anything
+ 2
So if you have a class Shape, with a static count variable, it can be accessed by all shape instances:
Shape shape1 = new Shape();
Shape shape2 = new Shape();
shape1.count = 2;
System.out.println(shape2.count); // 2
+ 2
Static code is being held in the RAM as to my knowledge. That is because it is shared across all instances. Meaning you can use it without creating an object etc.
0
Across all instances what do you mean by that
0
Iam sorry but I didn't get those.?
0
What do you mean by "those"?
0
I raised a question about the instances right iam not getting that right.?