+ 1

Why do we use static in Java?

In hello world, just after declaring class

26th Nov 2017, 10:55 AM
Rizan
Rizan - avatar
3 Respostas
+ 3
Because without static, you have to create an Object of the class. Because there aren't any objects before your main function is called, it has to be declared as static.
26th Nov 2017, 11:17 AM
Jonas Schröter
Jonas Schröter - avatar
+ 3
Just soo you can avoid the laziness of instantiating objects for that class before you can use its variables and methods
26th Nov 2017, 11:59 AM
᠌᠌Code X
᠌᠌Code X - avatar