Where to use the static in Java..?
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.
In Java, static keyword is mainly used for memory management.
To run your code,
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.