How to call a non-static method in static method with Java

1 Answer

0 votes
public class MyClass {
    public void nonStaticMethod() {
        System.out.println("nonStaticMethod()");
    }
    public static void main(String args[]) {
        MyClass object = new MyClass(); 
        
        object.nonStaticMethod();  
    }
}




/*
run:

nonStaticMethod()

*/

 



answered Oct 16, 2023 by avibootz

Related questions

1 answer 200 views
1 answer 154 views
1 answer 182 views
1 answer 220 views
1 answer 167 views
...