1 / 7

class 가수 {… class Trot extends 가수 {… class K_Pop extends 가수 {…

class 가수 {… class Trot extends 가수 {… class K_Pop extends 가수 {…. t. Trot t = new Trot(); t .name = “ 태진아 ” t .sing ();. k. K_Pop k = new K_Pop (); k .name = “ 소녀시대 ” k .sing (); k .dance ();. public static void main(String[] args ){

minowa
Télécharger la présentation

class 가수 {… class Trot extends 가수 {… class K_Pop extends 가수 {…

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. class 가수{… class Trot extends 가수{… class K_Pop extends 가수{…

  2. t Trott = new Trot(); t.name = “태진아” t.sing();

  3. k K_Popk = new K_Pop(); k.name = “소녀시대” k.sing(); k.dance();

  4. public static void main(String[] args){ ArrayList<가수> star = new ArrayList<가수>(); star.add( new Trot() ); star.get(0).name = “태진아”; star.add( new K_Pop() ); star.get(1).name = “소녀시대”;

  5. public static void main(String[] args){ ArrayList<가수> star = new ArrayList<가수>(); star.get(1).sing(); star star.get(1).dance();

  6. for( 가수 k : star ){ k.sing(); if( k instanceofK_Pop ){ ((K_Pop) k).dance(); } } downcasting

More Related