TOP > Java > ¥á¥½¥Ã¥É¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É |
¥ª¡¼¥Ð¡¼¥í¡¼¥É
¥ª¡¼¥Ð¡¼¥í¡¼¥É¤ÎÎã
class Test{ int add(int a) { return (a + 3 ) ; } int add(int a , int b){ return (a + b) ; } public static void main(String[] args){ Test t = new Test() ; System.out.println(t.add(3)) ;//¡ System.out.println(t.add(3,5)) ;//¢ } } ¡¤Ï¡¢°ú¿ô¤¬°ì¤Ä¤Îadd()¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë¡£¢¤Ï¡¢°ú¿ô¤¬Æó¤Ä¤Îadd()¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤·¤Æ¤¤¤ë¡£
¥ª¡¼¥Ð¡¼¥í¡¼¥É¤ÎÎã
class Animal{} class Pets extends Animal{} class Test{ void echo(Animal a){ System.out.println("Animal") ; } void echo(Pets p){ System.out.println("Pets") ; } public static void main(String[] args){ Test t = new Test() ; Animal a = new Animal() ; Pets p = new Pets() ; Animal ap = new Pets() ; t.echo(a) ; t.echo(p) ; t.echo(ap) ;//¡ } } ¡¤¬¥Ý¥¤¥ó¥È¡ªAnimal¥¯¥é¥¹»²¾È¤ÎPets¥ª¥Ö¥¸¥§¥¯¥È¤ò»Ø¤¹ÊÑ¿ô¤ò»È¤Ã¤¿¾ì¹ç¡¢¥ª¡¼¥Ð¡¼¥é¥¤¥É»þ¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤ò´ð½à¤Ë¼Â¹Ô»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¤¬¡¢¥ª¡¼¥Ð¡¼¥í¡¼¥É¥á¥½¥Ã¥É¤Ï¡¢¥³¥ó¥Ñ¥¤¥ë»þ¤Ë»²¾È·¿¡Ê¤³¤Î¾ì¹ç¡¢animal¥¯¥é¥¹¡Ë¤ò´ð½à¤Ë¤·¡¢°ú¿ô¤ÎÆͤ¹ç¤ï¤»¤Ï½ª¤ï¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢»²¾È·¿¤ò´ð½à¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¡£
|
Copyright 2007 ¤¿¤á¤Ë¤Ê¤ë¥Û¡¼¥à¥Ú¡¼¥¸ All Rights Reserved. |