SE450
:
Separating Accessors and Mutators
[24/57]
If we call a method to access an object, we don't expect the object to mutate
Rule of thumb:
Mutators should return
void
Example of violation:
Scanner in = . . .;
String s = in.next();
Yields current token
and
advances iteration
What if I want to read the current token again?