Static method and static variable

In Java, static denotes class methods and class variables (as opposed to instance methods and instance variables). These methods and variables can be accessed without an instance present.

Contrast this to instance methods and instance variables: they must be accessed through an object. For example, length() operates on an object:

In contrast, valueOf cannot operate on an object; moreover, it creates a new object when called:

Note how instance methods are called using <objectName> followed by a dot ., while static methods are accessed using <className> followed by a dot ..

Leave a Reply

Your email address will not be published. Required fields are marked *