728x90 ๋ฐ์ํ ๊ธฐ์ด1 [java๊ธฐ์ด] ์ ์บ์คํ ๊ณผ ๋ค์ด์บ์คํ - ์ํผ ํด๋์ค์ ๋ฉค๋ฒ ๋ชจ๋ ๊ฐ์ง๊ณ ์์ - ์ํผ ํด๋์ค์ ๊ฐ์ฒด๋ก ์ทจ๊ธํ ์ ์์ - ์๋ธ ํด๋์ค ๊ฐ์ฒด๋ฅผ ์ํผ ํด๋์ค ํ์ ์ผ๋ก ํ์ ๋ณํ class Person{ class Student extends Person{ Student s=new Student(); Person p=s; //์ ์บ์คํ p=(Person)s; ์๋ต ๊ฐ๋ฅ } } - ์ํผ ํด๋์ค ๊ฐ์ฒด๋ฅผ ์๋ธ ํด๋์ค ํ์ ์ผ๋ก ๋ณํ - ๊ฐ๋ฐ์์ ๋ช ์์ ํ์ ๋ณํ class Person{ class Student extends Person{ Person p=new Student("์ด์ ๋ฌธ")//์ ์บ์คํ Student s=(Student)p; // ๋ค์ด ์บ์คํ , (Student)์ ํ์ ๋ณํ ํ์ ํ์ } } - ์ ์บ์คํ ๋ ๋ ํผ๋ฐ์ค๋ก ๊ฐ์ฒด์ ํ์ ํ๋จ ์ด.. 2021. 7. 7. ์ด์ 1 ๋ค์ 728x90 ๋ฐ์ํ