Hi, this is part of an assignment question and probably something I should know.
I have 2 classes. I have a method in one class that creates an instance of the other class and sets one of its attributes to a certain value. The class that has its attribute set has a getter method for the attribute but no setter method. How can I set the atttribute? Should there be a setter? The question says nothing about writing a setter.
Thanks
Glen

If a class has a private attribute, and the developer didn't supply a setter, that means you're not supposed to set it (eg look at the get methods for the String class - you won't find any corresponding set methods because they don't want you to change a String object in any way). If it is required to set the value then there should be a set method to do that - maybe you need to write that, I can't say because I haven't seen the question.

Thats what I thought, I will email my tutor for confirmation of this.
Thanks...

This question has already been answered. Start a new discussion instead.