⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arraysortexample.java

📁 程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件
💻 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 + -