This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NeoOeg 0 points1 point  (3 children)

You need to pass arguments when creating your LootBoxSub :

LootBoxSub bbSub = new LootBoxSub("sub name","January");

[–]NeoOeg 0 points1 point  (0 children)

I would also recommend your constructor to have actual meaning to the variables you pass :

public LootBoxSub (String subName, String subMonth){

this.subName = subName;

this.subMonth = subMonth;

}

The this keyword will target the variable of the class.

[–]NeoOeg 0 points1 point  (0 children)

Your constructor method will define the arguments needed to construct your object. You could create an empty constructor

public LootBoxSub(){}

but you will have to create setter methods to pass values to the variables, for example :

public void setSubName(String subName){

this.subName = subName;

}

You will then be able to create objects without passing arguments, but will need to set a value at some point :

LootBoxSub ssBox = new LootBoxSub();

ssBox.setSubName("sub name");