0

Method calling

how can i use the method calling properly in java

8th Oct 2024, 7:44 PM
Lord Robertson Kundu
Lord Robertson Kundu - avatar
2 odpowiedzi
+ 4
methodOfThisClass(); object.method(); ClassName.staticMethod(); package.path.ClassName.staticMethod();
8th Oct 2024, 10:23 PM
zemiak
+ 3
1. Defining a Method public class MyClass { // Method definition public void myMethod() { System.out.println("Hello from myMethod!"); } } 2. Calling a Method public class MyClass { public void myMethod() { System.out.println("Hello from myMethod!"); } public void anotherMethod() { myMethod(); // Calling myMethod from anotherMethod } public static void main(String[] args) { MyClass obj = new MyClass(); obj.anotherMethod(); // This will call anotherMethod, which calls myMethod } }
9th Oct 2024, 11:42 AM
Aramayis Hayrapetyan