call method in class java 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: create object and call method in java
MyClass **insert_name** = new MyClass();
insert_name.**method_name**();