Jonas Grønbek Jonas Grønbek - 1 year ago 159
Java Question

Java create instance of class without the constructor arguments

I have this situation where i want to acces this Class, to call the getters. But if I try to create a object to prompt them, it will ask for arguments for the constructor.

package ansigtspilmit;

public class Card implements CardInterface {

String navn;
String[] labels;

Card(String navn, String... labels) {
this.navn = navn;
this.labels = labels;
}

@Override
public String getNavn() {
return navn;
}

@Override
public String[] getLabels() {
return labels;
}


}

Answer Source

you need to add an empty constructor without arguments

public Card(){};
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download