What are static methods and fields?

What is wrong with using a static method in a class like new Class().someStaticMethod()?

1 answers

Static methods and fields are class members. This means that they belong to the class, and not to an instance of the class. So, an instance of the class is not needed to gain access to these static members. The static fields are usually used for constants and the static methods for utility classes.

shilpigupta22 shilpigupta22 [Author] 4 months ago votes 0