Skip to main content

Posts

Showing posts from June 27, 2010

배열 복사 in Java

http://suein1209.tistory.com/450 public class ArrayClassTest { public static void main(String[] args) { /*clone 메소드를 사용한 배열 복사*/ int[] a = {1,2,3,4}; int[] b = a.clone(); /*arraycopy() 메소드를 사용한 배열 복사*/ int[] c = new int[a.length]; System.arraycopy(a, 0, c, 0, a.length); /*반복문을 이용한 배열 복사*/ int[] d = new int[a.length]; for (int i = 0; i <> d[i] = a[i]; } } } 이 3중, System.arraycopy 함수가 performance가 가장 좋다라고 한다.