아이템16 썸네일형 리스트형 [Effective JAVA] Item 16 public 클래스에서는 public 필드가 아닌 접근자 메서드를 사용하라 class Point { public double x; public double y; } 위와 같은 퇴보한 클래스는 데이터 필드를 직접 접근할 수 있음으로 캡슐화의 이점을 제공할 수 없다. class Point { private double x; private double y; public Point(double x, double y){ this.x = x; this.y = y; } public double getx(){ return this.x; } public double gety(){ return this.y; } public void setx(double x){ this.x = x; } public void sety(double y){ this.y = y; } } 이렇게 패키지 바깥에서 접근할 수.. 더보기 이전 1 다음