How to call static methods from a method in the same class in Java

1 Answer

0 votes
public class MyClass {
    public static void staticMethod1() {
         System.out.println("staticMethod1()");
    }
 
    public static void staticMethod2() {
         System.out.println("staticMethod2()");
         staticMethod1();
    }
    public static void main(String args[]) {
        staticMethod1();
        staticMethod2();
    }
}





/*
run:

staticMethod1()
staticMethod2()
staticMethod1()

*/

 



answered Jun 28, 2017 by avibootz
edited Oct 16, 2023 by avibootz

Related questions

1 answer 219 views
2 answers 250 views
1 answer 159 views
1 answer 202 views
1 answer 216 views
...