Static keyword

by mahidhar

Static keyword in Java can be used to declare whether a property or method is for class and not for an instance of the class. So, we do not need an object to to access/change the internal state of static variables. Usually we use static for methods which do not access or need any class level variables.

Ex: Utility methods which takes some inputs and returns some outputs without any dependencies on class variables are declared static.

Below is the sample that explains the behavior of "static" keyword applied at both variable/method level.

code
code