배열 복사 (clone)

han.user();·2023년 2월 26일
0
post-thumbnail
배열명.clone();
int[] a = {1,2,3}
int[] b = a.clone();

얼마 전에 배운...이런 메소드는 필요없었던 거였나...?

static void copy(int[] a, int[] b) {
	int num = a.length <= b.length ? a.length : b.length;
	for (int i = 0; i < num; i++)
		a[i] = b[i];

profile
I'm still hungry.

0개의 댓글