--Can be used without instantiation. --Since it is a method shared within the class, it can be accessed from other methods.
class TestClass {
private TestClass(){
}
//static method
public static void printlnHelloWorld() {
System.out.println("Hello World!");
}
}
Use of static methods
public class HelloWorld {
public static void main(String[] args) {
TestClass.printlnHelloWorld(); //No instantiation required
}
}
Recommended Posts