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