Java 1차원 배열, 1D array 배우기


public class Application{

     public static void main(String[] args){
       String[] numbers = new String[4];   //declaration important

   numbers[0] = "Welcome";

   numbers[1] = "To";

   numbers[2] = "My";

   numbers[3] = "Channel";
   for(int i = 0; i < 4 ; i++){

System.out.println(numbers[i]);

   }

   

   int[] Hi = new int[4];

   Hi[0] = 1

   Hi[1] = 2

   Hi[2] = 22

   Hi[3] = 44

   for(int j = 0 ; j < 4 ; j++){

       System.out.println(Hi[j]);

   }

}

}


[result]

Welcome

To

My

Channel

1

2

22

44

+ Recent posts