java call method from main class code example
Example 1: run a java class without main method
class StaticInitializationBlock{
static{
System.out.println("class without a main method");
System.exit(0);
}
}
Example 2: can i call another function from main hava
package learningjava;
public class helloworld {
public static void main(String[] args) {
new helloworld().go();
helloworld.get();
}
public void go(){
System.out.println("Hello World");
}
public static void get(){
System.out.println("Hello World, Again");
}
}