/*문제
1) 두 개의 배열이 있다. 한 배열의 값을 다른 배열로 복사하라!
2) 배열 데이터 예:
int[] list1 = {1, 2, 4, 7, 11, 9};
int[] list2 = new int[list1.length];
3) 출력 예:
list1: 1, 2, 4, 7, 11, 9
list2: 1, 2, 4, 7, 11, 9

 

 

class Test {   

 public static void main(String[] args) throws Exception {

   int[] list1 = {1, 2, 4, 7, 11, 9};
   int[] list2 = new int[list1.length];

   for (int i = 0; i < list1.length; i++) {
     list2[i] = list1[i];
   }

   System.out.print("list1: ");
   for (int i = 0; i < list1.length; i++) {
     System.out.printf("%s%d", (i == 0) ? "" : ", ", list1[i]);
   }

  }
}

Posted by 안낭우훗

블로그 이미지
좋은싸이트 공유, 재해석 , 공부 정리, 틀린거 알려 주세요~
안낭우훗

태그목록

공지사항

Yesterday
Today
Total

달력

 « |  » 2025.5
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

글 보관함