·Î±×ÀΠ| È¸¿ø°¡ÀÔ
ȦÀοø ¼Ò°³ µµ¼­ ¼Ò°³ °è¸®Á÷ ÄÄÀÏ¹Ý Àü»êÁ÷ 9±Þ Á¤º¸Ã³¸®ÀÚ°ÝÁõ ÀÚ·á´Ù¿î ÀÚÀ¯°Ô½ÃÆÇ
¾ÆÀ̵ð
Æнº¿öµå
Auto
¾ÆÀ̵ð / ºñ¹Ð¹øÈ£ºÐ½Ç    ȸ¿ø°¡ÀÔ


°í°´¼¾ÅÍ
¢Ï 010-3105-2441
¢Ï 070-7581-4923

³óÇù : 302-0573-1023-61
¿¹±ÝÁÖ : ÃÖÈñÁØ



¿À´Ã 69
¾îÁ¦ 188
ÃÖ´ë 1,112
Àüü 358,223
Home > ÀÚÀ¯°Ô½ÃÆÇ

 
ÀÛ¼ºÀÏ : 14-11-29 09:16
[ȦÀοø 7.06.08] È®Àι®Á¦ 02 ´äº¯
 ±Û¾´ÀÌ : ¿î¿µÀÚ
Á¶È¸ : 5,706  
Ŭ·¡½º°¡ 3°³ÀÔ´Ï´Ù..

¸ÞÀΠŬ·¡½º public class Adder_Main °¡ ÀÖ°í...
ÀÚ¹Ù¿¡¼­´Â ¸ÞÀΠŬ·¡½º¸í°ú ÆÄÀϸíÀÌ ¹Ýµå½Ã °°¾Æ¾ß ÇÕ´Ï´Ù..
Adder_Main.java 󷳿ä..


±×¸®°í »óÀ§(ºÎ¸ð) Ŭ·¡½º class Adder¿Í
ÇÏÀ§(ÀÚ½Ä) Ŭ·¡½º class Computer°¡ ÀÖ½À´Ï´Ù..
ÇÏÀ§ Ŭ·¡½º°¡ ºÎ¸ð Ŭ·¡½ºÀÇ »ó¼ÓÀ» ¹Þ°í ÀÖÁö¿ä..extends Adder
°á±¹ ÇÏÀ§ Ŭ·¡½º´Â »óÀ§ Ŭ·¡½ºÀÇ ¸â¹öº¯¼ö, ¸â¹öÇÔ¼ö(¸Þ¼Òµå)µéÀ» ¸ðµÎ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù..
Áï, »óÀ§ Ŭ·¡½ºÀÎ class Adder¿¡ Á¸ÀçÇÏ´Â µÎ °³ÀÇ add()ÇÔ¼ö¸¦ Æ÷ÇÔÇÑ´Ù°í »ý°¢ÇÏ¸é µÇÁö¿ä..


¿©±â¼­ ÇÑ Å¬·¡½º¿¡ µÎ °³ÀÇ µ¿ÀÏÇÑ ÇÔ¼ö¸í(add()°¡ µ¿ÀÏÇÑ°Ô Àִµ¥ Àμö³ª °³¼ö³ª À¯ÇüÀÌ ´Ù¸¥)À» °®°í ÀÖÀ» ¶§..
µ¿ÀÏÇÑ ¸Þ¼Òµå¸¦ ¸Þ½ÃÁö¿¡ µû¶ó ´Ù¸£°Ô ÀÀ´äÇÏ´Â ÀÌ°ÍÀ» ¿À¹ö·Îµù(Overloading)À̶ó°í ÇÏÁö¿ä.. 


±×¸®°í..
publicÀ¸·Î ¼±¾ðÇÑ ¸Þ¼Òµå³ª º¯¼öµéÀº ¾î´À Ŭ·¡½ºÀÌ´ø Á¢±ÙÀÌ °¡´ÉÇÕ´Ï´Ù..
privateÀ¸·Î ¼±¾ðÇÑ ¸Þ¼Òµå³ª º¯¼öµéÀº ¿ÜºÎ¿¡¼­´Â ¾Æ¿¡ ÀÖ´ÂÁö Á¶Â÷ ¸ð¸£Áö¿ä..

Adder_Main Ŭ·¡½º¿¡¼­ publicÀ¸·Î ¼±¾ðÇÑ add()³ª calc()·Î ¼±¾ðµÈ ¸Þ¼Òµå´Â
c.add()¿Í c.calc()·Î »ç¿ëÇÒ ¼ö ´Â ÀÖÁö¸¸..
¸¸¾à add()¿Í calc()À» private·Î ¼±¾ð Çß´Ù¸é
c.add()¿Í c.calc()·Î »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù..

Áö±Ý ¼Ò½º¿¡¼­
private int x; ·Î ¼±¾ðµÈ º¯¼ö´Â
Àý´ë c.x´Â Àý´ë »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù..


ÀÚ ¸ÞÀΠŬ·¡½º¸¦ ½ÃÀÛÇÕ´Ï´Ù..

Computer c = new Computer();
Computer °´Ã¼º¯¼ö c¸¦ ¼±¾ðÇÏ°í..
ÀνºÅϽº(½ÇÁ¦ °´Ã¼, ¸Þ¸ð¸® È®º¸)¸¦ »ý¼ºÇÑ ÈÄ,..
°´Ã¼ º¯¼ö c°¡ ÀνºÅϽº¸¦ °¡¸®Å°°Ô ÇÕ´Ï´Ù..
±×¸®°í ÀνºÅϽº¸¦ »ý¼ºÇÒ¶§..
»ý¼ºÀÚ ÇÔ¼öÀÎ Computer() { x = 0; }À» ¼öÇàÇÕ´Ï´Ù..
»ý¼ºÀÚ ÇÔ¼ö´Â Ŭ·¡½º¸í°ú µ¿ÀÏÇÑ °ÍÀÌ°í..
°´Ã¼¸¦ »ý¼ºÇÒ ¶§..ÀÚµ¿ ½ÇÇàÇÏ´Â ÇÔ¼öÀÌÁö¿ä..
²À º¯¼ö¸¦ ¼±¾ðÇϸ鼭 ÃʱâÈ­ÇÏ´Â °Í°ú °°Áö¿ä..


ù¹ø°...
----------------------------
System.out.println("100 + 200 = " + c.calc(1, 100, 200));
----------------------------
½Ã½ºÅÛ Áö¿ø °´Ã¼¸¦ ÀÌ¿ëÇÏ¿© È­¸é¿¡ 100 + 200 = À» Ãâ·ÂÇÕ´Ï´Ù..
System.out.println("100 + 200 = " +


±×¸®°í c.calc(1, 100, 200)ÀÇ °á°ú¸¦ Ãâ·ÂÇÕ´Ï´Ù..
c.calc(1, 100, 200)´Â ´ÙÀ½ÀÇ ¸Þ¼Òµå¸¦ È£ÃâÇÕ´Ï´Ù..
----------------------------
calc(int a, int b, int c)
      { if (a == 1)
            return add(b, c);       
-----------------------------
a=1. b=100, c=200À» ¸Å°³º¯¼ö·Î ¹Þ¾ÒÁö¿ä..
a°¡ 1ÀÌ´Ï ³Ñ°Ü ¹ÞÀº b¿Í c·Î add()¸¦ È£ÃâÇÏ°í ±× °á°ú°ªÀ» Á¤¼öÇü(calc()´Â intÇü) ¸®ÅÏÇÏ°Ô µË´Ï´Ù..

¸¸¾à..
c.calc(2, 100, 200)ÇüÅ·Π»ç¿ëÇß´Ù¸é...
-----------------------------
else return x;
-----------------------------
¼öÇàÇÒ °Ì´Ï´Ù..
»ý¼ºÀÚ ÇÔ¼ö¿¡¼­ ¸â¹ö º¯¼ö x¸¦ 0À¸·Î ÃʱâÈ­ ÇßÀ¸´Ï..¸®ÅÏ°ªÀÇ °á°ú´Â 0 ÀÌ°ÚÁö¿ä..

¾î·µç
add()¸¦ È£ÃâÇÏ·¯ °¡ºÃ´õ´Ï..
µÎ °³ÀÇ add() ÇÔ¼ö°¡ ÀÖ¾î¿ä..
¾î¶²°É »ç¿ëÇÒ±î¿ä.. b¿Í c°¡ Á¤¼öÇüÀÌ´Ï...
-----------------------------
public int add(int a, int b) { return a+b;}
-----------------------------
¸¦ »ç¿ëÇÏ°ÚÁö¿ä...

±×·¡¼­ bÀÇ 100Àº a°¡..cÀÇ 200Àº b°¡ ¹Þ¾Æ¼­ ´õÇÑ(a+b=300) °á°ú°ªÀ» Á¤¼öÇü(add()´Â intÇü) ¸®ÅÏÇÏ°Ô µË´Ï´Ù..
add(b, c)°¡ 300ÀÌ´Ï..calc(int a, int b, int c)µµ 300ÀÌ°ÚÁö¿ä..
°á±¹
-----------------------------
System.out.println("100 + 200 = " + c.calc(1, 100, 200));
-----------------------------
´Â 100 + 200 = 300ÀÌ Ãâ·Â µË´Ï´Ù..



µÎ¹ø°..
-----------------------------
System.out.println("5.7 + 9.8 = " + c.add(5.7, 9.8));
-----------------------------
5.7 + 9.8 = ¸¦ Ãâ·ÂÇÏ°í...c.add(5.7, 9.8)¸¦ È£ÃâÇÏ¿© ±× °á°ú°ªÀ» À̾ Ãâ·ÂÇÕ´Ï´Ù..


c.add(5.7, 9.8)´Â
Àμö(5,7, 9.8)°¡ ¹èÁ¤µµ ½Ç¼ö(double)ÀÌ´Ï...
-----------------------------
public double add(double a, double b) { return a+b;}
-----------------------------
¸¦ ¼öÇàÇÕ´Ï´Ù..5.7¿Í 9.8¸¦ ¹ÞÀº a, bÀÇ ´õÇÑ(a+b=15.5) °á°ú°ªÀ» ¹èÁ¤µµ½Ç¼öÇü(add()´Â doubleÇü) ¸®ÅÏÇÏ°Ô µË´Ï´Ù..
c.add(5.7, 9.8)°¡ 15.5ÀÌ´Ï..

-----------------------------
System.out.println("5.7 + 9.8 = " + c.add(5.7, 9.8));
-----------------------------
´Â
5.7 + 9.8 = 15.5°¡ Ãâ·ÂµË´Ï´Ù..

 
   
 


Sitemap Contact us Á¦ÈÞ¹®ÀÇ À̸ÞÀÏÁÖ¼Ò¹«´Ü¼öÁý°ÅºÎ

»óÈ£¸í : ȦÀοøÃâÆÇ»ç

   »ç¾÷ÀÚµî·Ï¹øÈ£ : 128-92-49854     ´ëÇ¥ : ÃÖÈñÁØ

ÁÖ¼Ò : °æ±âµµ ÀÇÁ¤ºÎ½Ã °¡´Éµ¿ 29-18È£ 4Ãþ

   ¹®ÀÇÀüÈ­ : 010-3105-2441    °³ÀÎÁ¤º¸°ü¸®Ã¥ÀÓÀÚ : ÃÖÈñÁØ

Åë½ÅÆǸŽŰí¹øÈ£ : Á¦2021-ÀÇÁ¤ºÎÈï¼±-0211È£

   [»ç¾÷ÀÚµî·Ï¹øȣȮÀÎ]    ÀüÀÚ¿ìÆíÁÖ¼Ò : nyuseoul@nate.com

copyright ¨Ï 2013~2025 onepassedu.com. All rights reserved.