正答例
| 
					 1 2 3 4 5  | 
						package challenge12; //比較処理用のインターフェース public interface SortItem{ 	boolean compare(Student student1,Student student2); }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13  | 
						package challenge12; //よみがなでソートするためのクラス public class Yomi implements SortItem{ 	@Override 	public boolean compare(Student student1, Student student2) { 		if( student1.getYomi().compareTo(student2.getYomi()) > 0 ) { 			return false; 		} 		return true; 	} }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12  | 
						package challenge12; //点数でソートするためのクラス public class Tensu implements SortItem{ 	@Override 	public boolean compare(Student student1, Student student2) { 		if( student1.getTensu() > student2.getTensu()) { 			return false; 		} 		return true; 	} }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12  | 
						package challenge12; //身長で比較するためのクラス public class Height implements SortItem{ 	@Override 	public boolean compare(Student student1, Student student2) { 		if( student1.getHeight() > student2.getHeight()) { 			return false; 		} 		return true; 	} }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  | 
						package challenge12; /*  * 生徒クラス(1名分)  */ public class Student { 	private String name;	//名前 	private String yomi;	//よみがな 	private int tensu;		//平均点数 	private double height;//身長 	//ゲッター/セッターメソッド 行が長くなるので改行を省略しています。 	public String getName() {return name;} 	public void setName(String name) {this.name = name;} 	public String getYomi() {return yomi;} 	public void setYomi(String yomi) {this.yomi = yomi;} 	public int getTensu() {return tensu;} 	public void setTensu(int tensu) {this.tensu = tensu;} 	public double getHeight() {return height;} 	public void setHeight(double height) {this.height = height;} 	//コンストラクタ 	public Student(String name,String yomi,int tensu,double height) { 		this.name = name; 		this.yomi = yomi; 		this.tensu = tensu; 		this.height = height; 	} }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49  | 
						package challenge12; /*  * 生徒用クラス  */ public class Students { 	private SortItem item;			//比較処理を格納するインタフェース変数 	Student[] students = {	//クラスstudentを配列にし生徒を表現 			new Student("佐藤","さとう",80,168.5), 			new Student("鈴木","すずき",20,156.0), 			new Student("高橋","たかはし",55,170.2), 			new Student("田中","たなか",35,145.5), 			new Student("伊藤","いとう",70,168.7), 	}; 	/* 	 * リスト表示 	 */ 	public void list() { 		for(int i=0;i<students.length;i=i+1) { 			System.out.println(students[i].getName()+"("+students[i].getYomi()+ 							"):点数="+students[i].getTensu()+":身長="+students[i].getHeight()); 		} 	} 	/* 	 * 比較処理の変更 	 */ 	public void changeItem(SortItem item) { 		this.item = item; 	} 	/* 	 * ソート処理 	 */ 	public void sort() { 		for(int i=0;i<students.length;i=i+1) { 			for(int j=students.length-1;j>i;j=j-1) { 				if(item.compare(students[i], students[j])){ //インタフェース変数により比較処理を呼び出す 					Student s = students[i]; 					students[i] = students[j]; 					students[j] = s; 				} 			} 		} 	} }  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51  | 
						package challenge12; import java.util.Scanner; public class Main { 	//各項目比較用のクラスを作成 	static Yomi yomi = new Yomi();		//よみがな 	static Tensu tensu = new Tensu();		//平均点数 	static Height height = new Height();	//身長 	//生徒リスト 	static Students students = new Students(); 	public static void main(String[] args) { 		int sel = select(); 		sort(sel); 		students.list();		//ソート結果表示 	} 	/* 	 * 並べる項目を選択 	 */ 	public static int select() { 	    Scanner scan = new Scanner(System.in); 	    System.out.println("並び替える項目を選択してください"); 	    System.out.println("1.名前"); 	    System.out.println("2.テスト"); 	    System.out.println("3.身長"); 	    System.out.println("-------------"); 	    return scan.nextInt(); 	} 	/* 	 * ソート処理呼び出し 	 */ 	public static void sort(int sel) { 		//選択された項目によりソート処理の比較クラスを入れ替える 		if( sel == 1) {		//名前 			students.changeItem(yomi); 		} 		if( sel == 2) {		//点数 			students.changeItem(tensu); 		} 		if( sel == 3) {		//身長 			students.changeItem(height); 		} 		//ソート処理呼び出し 		students.sort(); 	} }  | 
					

