Using several classes

I have problems in using several classes in my project.



I created a new class called mainCharacter (to have all the methods related to the main character). It extends the Main-class (public class mainCharacter extends Main{}).


  1. I import the class in the Main-class: import <classpath>.mainCharacter;
  2. I create an instance: public mainCharacter mc;
  3. I have a method in the mainCharacter.class called Test(). If I try to call it by typing mc.Test(); it only works if the method is empty. Why?



    If anyone had an example of using several classes, I would be happy!



    Thanks,

    OLLI

I would highly recommend:



http://thejavatutorial.com



darkfrog

You need to use the new comand to create a instances



You need to add:

mc =new mainCharacter ();



Java objects are similar to pointers in c++.