0

I did not exactly get about this (public static void).?

24th Aug 2019, 9:54 AM
Jyoti Prasad Kurmi
Jyoti Prasad Kurmi - avatar
7 Respostas
+ 3
public: It's accessible outside the class static: It's shared across all instances and the class void: Does not return anything
24th Aug 2019, 10:06 AM
Airree
Airree - avatar
+ 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
24th Aug 2019, 10:10 AM
Airree
Airree - avatar
+ 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.
24th Aug 2019, 12:19 PM
Tugay Mandal
0
Across all instances what do you mean by that
24th Aug 2019, 10:09 AM
Jyoti Prasad Kurmi
Jyoti Prasad Kurmi - avatar
0
Iam sorry but I didn't get those.?
24th Aug 2019, 10:12 AM
Jyoti Prasad Kurmi
Jyoti Prasad Kurmi - avatar
0
What do you mean by "those"?
24th Aug 2019, 10:14 AM
Airree
Airree - avatar
0
I raised a question about the instances right iam not getting that right.?
24th Aug 2019, 10:20 AM
Jyoti Prasad Kurmi
Jyoti Prasad Kurmi - avatar