//교재143p
public class Class4 {
public static void main(String[] args) {
//클래스를 사용(이용)하기 위해서는 객체 생성이 필요하다
Point2 p; //선언,String name;
p = new Point2(); //객체 만드는 문법.
System.out.println(p.y);//p객체안의 y필드값
//x값을 알고 싶다
//System.out.println(p.x);//is not visible
System.out.println(p.getX());
WestWomen women=new WestWomen();
//System.out.println(women.age);//데이터 은닉
System.out.println(women.getAge());
}
}
class WestWomen{
private int age=30;
private boolean isMarried=false;
public int getAge(){
return age;
}
}
class Point2{
//필드
private int x=100; //private 접근 지정자 (Data Hiding,은닉)-교재136p
public int y=200;
public int getX(){
return x;
}
}