Tuesday, 20 August 2013

How can I initialize a class with constructor?

How can I initialize a class with constructor?

So I have this Contructor:
public MyClass(boolean done, int lvl , String s, int x, int y, Skill
parent, Item item, int cost) {
this.done = done;
this.lvl = lvl;
this.name = s;
this.Xpos = x;
this.Ypos = y;
this.parent = parent;
this.item = item;
addSkill(this, s);
}
Is there a way for me to use/initialize this in another class without
having to do
MyClass myclass = new MyClass(false, 0, "", 0, 0, null, this.item, 1)
If I just do
MyClass myclass;
Then I get the "horrid" null pointer exception.

No comments:

Post a Comment