작성
·
212
0
Getter method 나 setter method 을 나누는 기준은 본인의 메서드가 포함되어 있는 class 내의 instance variables 를 변경시키느냐 마느냐에 따라 다른가요 ?
예로
public class Hello {
private int result;
public int method1() {
result = (int)(Math.random() * 2) + 4;
return result;
}
}
우리는 Math.random() static method 를 accesor method 라고 부르나요? 아니면 mutator method 라고 부르나요 ?
저는 Math.random 이 result 값 즉, 필드변수의 값을 변경시키는데 영향을 끼치고 있으므로 Mutator method 라고 생각했는데 이렇게 생각해도 괜찮나요?