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 197 views
1 answer 146 views
1 answer 174 views
1 answer 210 views
1 answer 162 views
...