JAVA/예제

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

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

class  Data{
    int x;
}

728x90

댓글