STUDY/JAVA38 this의 의미 this?자기 자신 클래스를 가르킴.객체 자신에 대한 참조값을 갖는다.this를 사용함으로서 모호하지 않고 명확한 프로그램을 작성할 수 있다.public class AClass { Integer i; Integer j; static int TEMP = 10; // 생성자 public AClass(Integer i, Integer j) { super(); this.i = i; // AClass클래스의 변수를 가르킴. this.j = j; }}Colored by Color Scriptercsthis.i 는 AClass의 i를 뜻한다. 2018. 1. 22. 초기화와 생성자 초기화와 생성자를 알아보자. 생성자의 특징- 값을 반환하지 않는다. - 생성자는 인스턴스를 생성해주는 역할을 하는 특수한 메소드. - 생성자의 이름은 클래스의 이름과 동일. 아래 코드를 보자. public class AClass { Integer i; Integer j; // 생성자 public AClass(Integer i, Integer j) { super(); this.i = i; this.j = j; } public void sum(){ System.out.println(this.i + this.j); } }Colored by Color Scriptercs생성자를 선언. 클래스이름과 생성자의 이름이 같은 걸 알 수 있다.public class JAVA_TEST { public static void.. 2018. 1. 22. 이전 1 ··· 7 8 9 10 다음