Java SE/Comparable<T> example 썸네일형 리스트형 Comparable<T> example package utils; import java.util.*; /* Comparable인터페이스를 구현한 클래스는 Arrays.sort()에 의해서 정렬될 수 있다. 이 예제는 Comparable인터페이스를 사용하여 객체배열을 정렬하는 예를 보인 것이다. */ public class ArrayTest { public static void main(String[] args) { Student[] std = new Student[3]; std[0] = new Student(3, "홍길동"); std[1] = new Student(1, "장미란"); std[2] = new Student(2, "박세리"); Arrays.sort(std); // 객체배열의 원소를 정렬한다(Comparable인터페이스를 구현한 경.. 더보기 이전 1 다음