+ 1

Where to use the static in Java..?

12th Oct 2020, 2:57 PM
Nitin Jibhau Gangurde
Nitin Jibhau Gangurde - avatar
5 Respostas
+ 3
Nitin Jibhau Gangurde The static keyword is can be used with variable, method, block, and class. It is used to manage the memory in java. The static keyword always belongs to class instead of objects.
12th Oct 2020, 4:45 PM
Raina Dhankhar
Raina Dhankhar - avatar
+ 2
In Java, static keyword is mainly used for memory management.
12th Oct 2020, 3:07 PM
Matias
Matias - avatar
+ 1
To run your code,
12th Oct 2020, 3:05 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 1
About Class, static method and variable. Remeber you need create a object? Person peopleOne = new People("My name"), for example.. In class Person have: String name; each people have different name. calling the name of one person: peopleOne.name; Now imagine every time you create a Person you want save how many are created. So it is not for the unique Person. You can create: static int quantit; Call: PersonClass.quantit; I don't need create any person to use it. For me it's most different, you can use static method and variable without creating a object.
13th Oct 2020, 1:11 AM
Marcelo Anjos
Marcelo Anjos - avatar
0
Thanks
13th Oct 2020, 3:24 AM
Nitin Jibhau Gangurde
Nitin Jibhau Gangurde - avatar