一個(gè)簡(jiǎn)單的排序問(wèn)題 -電腦資料

電腦資料 時(shí)間:2019-01-01 我要投稿
【clearvueentertainment.com - 電腦資料】

    1.首先定義一個(gè)接口

package temp.test;public interface IntCompare {	public int compare(int a, int b);}

    2.分別定義兩個(gè)接口實(shí)現(xiàn)類(lèi),一個(gè)增序,一個(gè)減序

    增序:

package temp.test;public class IncreaseOrder implements IntCompare{	@Override	public int compare(int a, int b) {		// TODO Auto-generated method stub		if(a>b){			return -1;		}else if(a<b></p><p>    降序:</p>

    4.測(cè)試結(jié)果

    1234554321

最新文章