Learning static modifier in Java

in hive-109160 •  4 years ago  (edited)

The static modifier in java directly relates to the class and not to the instance of the class. They are advantageous in the sense that you don't need to create an object each time to access the methods.

image.png

In the above code there's no any instance of the class named as MyClass to access the method which is firstMessage(). It's because whenever you used the static modifier, you don't need to create the instance of the object.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!