Java
[Java] ๋ถ๋ชจ๋ฅผ ๋ถ๋ฅด๋ ์์ฝ์ด, super
์ฝ๋ฉํ๋ ๋ถ์ด
2021. 2. 19. 03:50
๋ฐ์ํ
โถ ๋ถ๋ชจ๋ฅผ ๋ถ๋ฅด๋ ์์ฝ์ด, super
super ์์ฝ์ด๋ ํ์ ํด๋์ค์์ ์์ ํด๋์ค๋ก ์ ๊ทผํ ๋ ์ฌ์ฉํ๋ค.
this๊ฐ ์๊ธฐ ์์ ์ ์ฐธ์กฐ ๊ฐ์ ๊ฐ์ง๊ณ ์๋ ๊ฒ๊ณผ ๊ฐ๋ค๊ณ ์๊ฐํ๋ฉด ๋๋ค.
โ



package inheritance;
public class CustomerTest2 {
public static void main(String[] args) {
VIPCustomer customerKim = new VIPCustomer(10020, "๊น์ ์ "); // ํ์ ํด๋์ค ์์ฑ
// customerKim.setCustomerID(10020);
// customerKim.setCustomerName("๊น์ ์ ");
customerKim.bonusPoint = 10000;
System.out.println(customerKim.showCustomerInfo());
}
}
<์คํ ๊ฒฐ๊ณผ>

๋ฐ์ํ