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

📄 algorithmexample.java

📁 这是清华大学编写的JAVA教材中所有题目的源代码!
💻 JAVA
字号:
import java.util.*;

class AlgorithmExample 
{
  public static void main(String args[]) 
  {
    ArrayList al = new ArrayList();
    al.add(new Integer(10));
    al.add(new Integer(35));
    al.add(new Integer(54));
    al.add(new Integer(26));
    System.out.println("初始列表为: ");
    System.out.println(al+"\n");
    
    System.out.println("列表中的最大值为:"+Collections.max(al));
    System.out.println("列表中的最小值为:"+Collections.min(al)+"\n");
    
    Collections.reverse(al);
    System.out.println("列表逆序后为: ");
    System.out.println(al+"\n");
    
    Collections.sort(al);
    System.out.println("列表排序后为: ");
    System.out.println(al+"\n");
    
    int index=Collections.binarySearch(al,new Integer(54));
    System.out.println("元素54的位置为: ");
    System.out.println(index+"\n");
    
    Collections.fill(al,"hello");
    System.out.println("列表用hello填充后为: ");
    System.out.println(al+"\n");
    
    ArrayList bl = new ArrayList();
    bl.add("1");
    bl.add("2");
    bl.add("3");
    Collections.copy(al,bl);
    System.out.println("列表用bl的元素替代后为: ");
    System.out.println(al+"\n");
    
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -