#simple question

11 messages · Page 1 of 1 (latest)

winged mauve
#

Just wondering how I update the instance of this class or whatever it's called. If i make something like this: Area wcArea = new Area(3174, 3235, 3222, 3253); how would I later change the values of wcArea? thanks

teal crystalBOT
#

This post has been reserved for your question.

Hey @winged mauve! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

gentle valley
#

Depends on what class Area proposes. Some classes are said immutable: they don't allow to change the values that were set after construction.

winged mauve
gentle valley
#

Like I said, it depends on what class Area proposes. In other words, by what mechanism is it not immutable

hallow oar
#

you can then modify them by doing:

Area wcArea = new Area(50, 50, 100, 100);
wcArea.a = 100;
// changing other area boundaries as necessary
#

You can also use getter or setter functions if you need something more complex or the variables need to be private

gentle valley
#

Fundamentally, setters are an established expectation in Java, even it it smells like cargo cult

sudden cosmos