728x90 자바 객체 생성2 [JAVA] ch05-03. 객체 생성 2 public class Ex03 { public static void main(String[] args){ Tv t1 = new Tv(); Tv t2 = new Tv(); System.out.println("t1.channel: "+ t1.channel); System.out.println("t2.channel: "+ t2.channel); t2 = t1; t1.channel = 7; System.out.println("t1.channel: "+ t1.channel); System.out.println("t2.channel: "+ t2.channel); } } JAVA/예제 2017. 8. 22. [JAVA] ch05-02. 객체 생성 public class Ex02 { public static void main(String[] args){ Tv t1 = new Tv(); //새로운 객체 생성 //t2와 별도의 객체 Tv t2 = new Tv(); System.out.println("t1.channel: " + t1.channel); System.out.println("t2.channel: " + t2.channel); t1.channel = 7; System.out.println("t1.channel: " + t1.channel); System.out.println("t2.channel: " + t2.channel); } } JAVA/예제 2017. 8. 22. 이전 1 다음 728x90