20220204 º¹½À

¹è¿­ »ý¼º : ÀÚ·áÇü[ ] º¯¼ö¸í = ÀÚ·áÇü [¹è¿­±æÀÌ]
¹è¿­Àº for ¹Ýº¹¹® »ç¿ë!
i = 0 | 1 | 2 | 3 | 4
°ª 1 | 2 | 3 | 4 | 5

ÁÖ¼Ò ¾È¿¡ °ªÀÌ ÀúÀåµÇ¾î ÀÖ°í, for¹®À» ÀÌ¿ëÇÏ¿© ¹è¿­ÀÇ ÁÖ¼Ò¸¦ ½Ï´Ù ºÒ·¯¿Â´Ù!
int[ ] a = new int [ ] [ ] -> 2Â÷¿ø ¹è¿­ : °¢ ¿ø¼Ò ¾È¿¡ ¶Ç ¹è¿­ÀÌ µé¾î ÀÖ´Ù.
                            
¹è¿­À» »ç¿ëÇÏ¿© ÇÔ¼ö¸¦ ¸¸µé¾îº¸ÀÚ.
class T0204_22
{
     static int test(int[] a){ //¹Ýº¹¹® »ç¿ë!
          int sum=0;
          for (int i=0;i<5 ;i++ )
          {
               sum+=a[i];
          }

          return sum;
     }
     public static void main(String[] args)
     {
          int[] a = new int[5];
          a[0]=1;
          a[1]=2;
          a[2]=3;
          a[3]=4;
          a[4]=5;

          int result=0;
          result=test(a); //È£Ãâ
          System.out.println(result);
     }
}

¹®ÀÚ¿­ ¹è¿­À» ÀÌ¿ëÇÏ¿© ÇÔ¼ö¸¦ ¸¸µé¾îº¸ÀÚ
class T0204_23//ÀÔ·ÂÇÑ À̸§ÀÌ µ¥ÀÌÅÍ ¾È¿¡ Á¸ÀçÇÏ´ÂÁö ¾Ë¾Æº¸´Â ÇÁ·Î±×·¥
{
   static void checkName(String[] name, String inputName){
      int i=0;
      for (i=0;i<3 ;i++ )
      {
         if (inputName.equals(name[i]))
         {
             System.out.println("À̸§ÀÌ Á¸ÀçÇÕ´Ï´Ù.");
             break;
         }else{
             System.out.println("À̸§ÀÌ Á¸ÀçÇÏÁö ¾Ê½À´Ï´Ù.");
         }
         
      }
   }
   public static void main(String[] args)
   {
      String[] name = new String[3];
      String inputName;
      name[0]="kim";
      name[1]="lee";
      name[2]="park";

      inputName="kim";
      
      checkName(name,inputName);
      
      
   }
}