+ 2
What did static do in program? Is static is compulsory or nt?
5 Respuestas
+ 2
static means that a methos or field belongs to the whole class, that means it is not invoked on an instance
static methods are invoked ClassName.method()
non-static: variable.method()
main must be static, all fields and methods you access directly (not through obj.something) from static method must be static
for example when you have ArrayList's method size(), it is not static because every concrete ArrayList has its own size
Double.parseDouble() is static, because the whole class Double provides one way to convert String to double
+ 19
+ 3
before starting working with objects, every your method is static
main is always static
+ 1
can u explain me in simple language??
+ 1
In simple language, I think that it can be resumed like this: if you are not using objects, put static. if you are, dont put it.