JAVA/예제

[JAVA] ch05-10. 클래스와 메서드에서의 객체 호출 2

밍글링글링 2017. 8. 22.
728x90
 
public class Ex10 {
    public static void main(String[] args){
        Data d = new Data();
        d.x =10;
        System.out.println("main():x = "+d.x);
        
        Ex10 e = new Ex10();
        e.change(d);
        System.out.println("main():x = "+d.x);
    }
    void change(Data d){
        d.x = 1000;
        System.out.println("change():x= "+d.x);
    }
}

//Data class in Ex09

728x90

댓글