/**
* 排序抽象类
* Created by Anbang713
*/
public abstract class AbstractSort implements Sortable {
@Override
public void display(int[] array) {
if (array == null || array.length == 0) {
return;
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i] + " ");
}
System.out.println();
}
public void test(int[] array) {
if (array == null || array.length == 0) {
return;
}
System.out.println("未排序数组顺序为:");
display(array);
System.out.println("-----------------------");
array = sort(array);
System.out.println("-----------------------");
System.out.println("排序后的数组顺序为:");
display(array);
}
}
/**
* 可排序接口
* Created by Anbang713
*/
public interface Sortable {
/**
* 对数组进行排序
*
* @param array
* 待排序数组
* @return 排序后数组
*/
int[] sort(int[] array);
/**
* 数组展示
*
* @param array
* 数组
*/
void display(int[] array);
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史