this

· JAVA
들어가며JAVA에서 this와 this()는 비슷하게 생겼지만 엄연히 다르다. 어떠한 차이가 있는지 예제 코드를 통해 이해해보자. this생성자의 매개변수의 ≠ 이름 인스턴스 변수의 이름class Car { String color; String gearType; int door; Car(String a, String b, int c){ color = a; gearType = b; door = c; } public static void main(String[] args) { Car c = new Car("black", "auto", 3); System.out.println(c.color); System.out.println(c.gearType); System.out.println(c.door); } } t..
팁택톡
'this' 태그의 글 목록