Sabtu, 31 Juli 2021

When to Make a Method Static in Java? Example

Making a method static in Java is an important decision. Though, static keyword is one of the fundamental concepts, many times programmers get confused to make a particular method static or not. In Java programming, the main motivation for making a method static is convenience. You can call a static method without creating any object, just by using its class name. So if you need a method, which you want to call directly by class name, make that method static. Utility classes e.g. java.lang.Math or StringUtils are good examples of classes, which use static methods. Before making a method static, you should look into the limitations of static methods as well, as you can not override static methods in Java

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon