Вопрос

In System.out.println, println is a accessor or mutator method in JAVA ?

Thank you....

Это было полезно?

Решение

I would say it's neither. It only exists for its side effects; it is not obliged to do anything at all to the internal state of System.out (which is what accessors and mutators are about).

Другие советы

It's not an accessor, because it doesn't return a value (it's void). One could argue that it's a mutator, because it modifies the state of the underlying I/O system (it has side effects), but it's not a clear-cut distinction, because is not modifying the state of the System class or any of its instances.

The accessor/mutator distinction generally applies to methods that return a value obtained from an object's attributes (accessors) or methods that modify those attributes (mutators), but this is not the case for println(), the state being modified (an output stream) lies outside of the class.

No. Accessors are "getXXX", mutators are "setXXX". println is neither.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top