Java

Static vs. non-static methods

If you want to use a method without creating an instance of that class, static methods are the way to go. If your method is related to an instance’s attributes, it should be non-static.

Static MethodsNon-Static Methods
Class methodInstance method
Belongs to the class itselfBelongs to each object generated from the class
Does not need an instance to useNeeds an instance to use
Method depends on classMethod depends on object’s characteristics

Leave a Reply

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