Apart from class and instance variables, Java also has class and instance methods. The differences between the two types of method are analogous to the differences between class and instance variables. Class methods are available to any instance of the class itself and can be made available to other classes. Therefore, some class methods can be used anywhere, regardless of whether an instance of the class exists or not.
In order to define class methods, the keyword static is used. This keyword should be placed in front of the method definition.
For example, the following illustration defines a class method named Max.
static int Max(int arg1. int arg2) { ... }
In Java, each data type has a wrapper class. Wrapper classes for integer, float and boolean data types are Integer, Float and Boolean, respectively. By using class methods defined in these classes, objects can be converted into data types and vice versa. For example, the parselnt() class method in the Integer class takes a string and a radix (base) and returns the value of that string as an integer:
int count = Integer.parselnt("42", 10) //returns 42
Usually methods that operate on a particular object and affect it in one way or the other are defined as instance methods. Methods that provide some general utility but do not directly affect an instance of that class are declared as class methods.