0

What is the meaning of "java static"?

Static in java

25th Apr 2019, 2:34 PM
Jaliya Roshen
Jaliya Roshen - avatar
3 odpowiedzi
+ 16
• Static or class fields belong to a class, not to an object class Point{     double x;     double y;     static double xorigin = 0.0;     static double yorigin = 0.0; } System.out.println(     "The origin is at ("+       Point.xorigin +", "+       Point.yorigin +")" ); You access class variables with the name of the class rather than a reference variable.
25th Apr 2019, 4:39 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 12
Variables and methods marked 'static' belong to the class, rather than to any particular instance. In fact, you can use a 'static' method or variable without having any instances of that class at all. You need only have the class available to be able to invoke a 'static' method or access a 'static' variable. 'static' variables, too, can be accessed without having an instance of a class. But if there are instances, a 'static' variable of a class will be shared by all instances of that class; there is only one copy. https://code.sololearn.com/W2LnAYam75y4/?ref=app
25th Apr 2019, 4:19 PM
Danijel Ivanović
Danijel Ivanović - avatar
0
Some people say.. "Static" means "UNCHANGED" ?
26th Apr 2019, 2:32 AM
Jaliya Roshen
Jaliya Roshen - avatar