What are static methods and fields?


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


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.

0 answers