import java.util.Arrays; import java.util.Scanner; public class aa { public static class stu implements Comparable{ int a; int b; stu(){}//無參構造 stu(int a,int b){ this.a = a; this.b = b; } @Override public int compareTo(Object o){ stu s = (stu) o; return a - s.a; } } public static void main(String[] args) { // TODO Auto-generated method stub stu[] no = new stu[4]; no[0] = new stu(2,3); no[1] = new stu(5,99); no[2] = new stu(-43,88); no[3] = new stu(66,30); Arrays.sort(no); for(int i = 0;i < no.length;i++){ System.out.println(no[i].a); } return; } }