📄 arraysortexample.java
字号:
package examples.collections;
import java.util.*;
/** A class to demonstrate the use of the sort and
* search algorithms in the java.util package
*/
public class ArraySortExample {
/** Test method for the class
* @param args not used
*/
public static void main( String[] args ) {
// create a list and intialize it
Object[] data = { new Double( 3.45 ),
new Double( -0.2 ),
new Double( 100.3 ),
new Double( 89.67 ),
new Double( 11.0 ),
new Double( 23.132 )
};
List list = Arrays.asList( data );
// iterate to display the set values
Iterator i1 = list.iterator();
while ( i1.hasNext() ) {
System.out.print( i1.next() + " " );
}
System.out.println();
Collections.sort( list );
Iterator i2 = list.iterator();
while ( i2.hasNext() ) {
System.out.print( i2.next() + " " );
}
System.out.println();
for( int j=0; j<data.length; j++ ) {
System.out.print( data[j] + " " );
}
System.out.println();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -