I am attempting to get one class to return a string from another class, though the return I get is null. I have a set method that works in setting the string in the original cla
In IceCream class constructor you have:
String flavour = getFlavour()
You have created a local variable instead a reference to a instance property. getFlavour() method return the property instance that you never set, so its null. You should have something like this in the constructor:
this.flavour = "default value";
Or set a flavour parameter on constructor header:
public IceCream(String flavour) {
this.flavour = flavour;
(...)
}
And call it like:
IceCream chocolat = new IceCream(" chocolat");
And if you want change the flavour use the setter.