Calling a non-static method with constructors using objects from a different class [duplicate]

Your understanding:

I cannot call a non-static method from a a method of a different class.

is wrong.

If you have created the object of the class containing the non-static method, you can call it.

You get a null pointer exception because the constructor of the ClassA does something with the CommandControl ab. And that ab is null in your case.

Leave a Comment