+ 1

What is static ?

what is the meaning of static in java.

30th Jun 2017, 3:51 AM
Prithvi Raj
Prithvi Raj - avatar
4 Respostas
+ 10
If you're just starting with Java, the short answer is "don't worry about it". You'll find out about it later. The long answer is that static allows you to use a class without making an object from it. The class main() is in must be static, because no code can run that can create any objects until main() starts. If that class and main() isn't static, main() can't run.
30th Jun 2017, 4:20 AM
Tamra
Tamra - avatar
+ 3
static makes the member bound to the class. Without the use of static the member would be from an instance of the class. The result of this is what the others are saying, where you don't need to make an instance of the class to access the member.
30th Jun 2017, 4:21 AM
Rrestoring faith
Rrestoring faith - avatar
+ 2
Static allows you to call a method, even if you never created an object to which that method would belong to. Also static members variables are shared by all instances of the class to which they belong.
30th Jun 2017, 4:18 AM
isk
isk - avatar
+ 1
30th Jun 2017, 6:58 AM
Saikat Mukherjee
Saikat Mukherjee - avatar