java call a function from main code example
Example 1: calling method in java
public class MyClass {
void myMethod() {
System.out.println("You have called me! My name is: myMethod!");
}
public static void main(String[] args) {
new MyClass().myMethod();
}
}
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");
}
}