import
java.util.
*
;
/**
* @(#)SortTest.java
*
* SortTest application
*
* @author
* @version 1.00 2007/3/15
*/
public class SortTest {
public static void main(String[] args) {
// TODO, add your application code
System.out.println( " Hello World! " );
double [] array = { 123 , 456 , 23 , 23 , 78 , 897 };
List list = new ArrayList();
List li = new ArrayList();
for ( int i = 0 ; i < array.length; i ++ ){
list.add( new Double(array[i]));
}
System.out.println( " 原始: " + list.toString());
// 升序
Collections.sort(list);
System.out.println( " 升序: " + list.toString());
// 混排
Collections.shuffle(list);
System.out.println( " 混排: " + list.toString());
// 降序
Collections.reverse(list);
System.out.println( " 降序: " + list.toString());
// 替换
List l2 = new ArrayList();
for ( int i = 0 ; i < list.size(); i ++ ){
l2.add(list.get(i));
}
Collections.fill(l2, " test " );
System.out.println( " 替换后: " + l2);
System.out.println( " 替换后的原始值: " + list);
// 拷贝
double [] num = { 1024 , 768 };
List l3 = new ArrayList();
for ( int i = 0 ; i < num.length; i ++ ){
l3.add( new Double(num[i]));
}
System.out.println( " 拷贝源: " + l3.toString());
Collections.copy(list, l3);
System.out.println( " 拷贝完成,目标为: " + list.toString());
// 最小值
System.out.println( " 最小值是: " + Collections.min(list));
// 最大值
System.out.println( " 最大值是: " + Collections.max(list));
// lastIndexOfSubList
double [] num2 = { 23 };
List l4 = new ArrayList();
for ( int i = 0 ; i < num2.length; i ++ ){
l4.add( new Double(num2[i]));
}
System.out.println( " : " + Collections.lastIndexOfSubList(list, l4));
// IndexOfSubList
double [] num3 = { 23 };
List l5 = new ArrayList();
for ( int i = 0 ; i < num3.length; i ++ ){
l5.add( new Double(num3[i]));
}
System.out.println( " : " + Collections.indexOfSubList(list, l5));
// 旋转
System.out.println( " 旋转前: " + list);
Collections.rotate(list, - 2 );
System.out.println( " 旋转(正向): " + list);
}
}
/**
* @(#)SortTest.java
*
* SortTest application
*
* @author
* @version 1.00 2007/3/15
*/
public class SortTest {
public static void main(String[] args) {
// TODO, add your application code
System.out.println( " Hello World! " );
double [] array = { 123 , 456 , 23 , 23 , 78 , 897 };
List list = new ArrayList();
List li = new ArrayList();
for ( int i = 0 ; i < array.length; i ++ ){
list.add( new Double(array[i]));
}
System.out.println( " 原始: " + list.toString());
// 升序
Collections.sort(list);
System.out.println( " 升序: " + list.toString());
// 混排
Collections.shuffle(list);
System.out.println( " 混排: " + list.toString());
// 降序
Collections.reverse(list);
System.out.println( " 降序: " + list.toString());
// 替换
List l2 = new ArrayList();
for ( int i = 0 ; i < list.size(); i ++ ){
l2.add(list.get(i));
}
Collections.fill(l2, " test " );
System.out.println( " 替换后: " + l2);
System.out.println( " 替换后的原始值: " + list);
// 拷贝
double [] num = { 1024 , 768 };
List l3 = new ArrayList();
for ( int i = 0 ; i < num.length; i ++ ){
l3.add( new Double(num[i]));
}
System.out.println( " 拷贝源: " + l3.toString());
Collections.copy(list, l3);
System.out.println( " 拷贝完成,目标为: " + list.toString());
// 最小值
System.out.println( " 最小值是: " + Collections.min(list));
// 最大值
System.out.println( " 最大值是: " + Collections.max(list));
// lastIndexOfSubList
double [] num2 = { 23 };
List l4 = new ArrayList();
for ( int i = 0 ; i < num2.length; i ++ ){
l4.add( new Double(num2[i]));
}
System.out.println( " : " + Collections.lastIndexOfSubList(list, l4));
// IndexOfSubList
double [] num3 = { 23 };
List l5 = new ArrayList();
for ( int i = 0 ; i < num3.length; i ++ ){
l5.add( new Double(num3[i]));
}
System.out.println( " : " + Collections.indexOfSubList(list, l5));
// 旋转
System.out.println( " 旋转前: " + list);
Collections.rotate(list, - 2 );
System.out.println( " 旋转(正向): " + list);
}
}