카테고리 없음
sort() - Arrays.sort(), Collections.sort()
그릿GRIT
2021. 8. 3. 14:51
728x90
int 배열이나 String 배열을 정렬 시킬때 Arrays 클래스를 사용한다.
int[] a = {7,8,65,2,1,6,9};
Arrays.sort(a);
List를 상속받는 ArrayList, Vector, LinkedList를 정렬시킬때는 Collections 클래스를 사용한다.
Vector<Integer> test = new Vector<Integer>(3,4);
test.add(6);
test.add(4);
test.add(8);
test.add(10);
Collections.sort(test);