• 使用HashMap,put()表示放置元素,get()表示取元素


    SortedSet可自动为元素排序。

    SortedSet的实现类是TreeSet:它的作用是字为添加到TreeSet中的元素排序。

    与HashSet不同,TreeSet并不需要实现HashCode()和equals()。

    只要实现compareable和compareTo()接可以实现过滤功能。

    (注:HashSet不调用CompareTo())。

    如果要查询集合中的数据,使用Set必须全部遍历,所以查询的效率低。使用Map,可通过查找key得到value,查询效率高。

    集合中常用的是:ArrayList,HashSet,HashMap。其中ArrayList和HashMap使用最为广泛。

    使用HashMap,put()表示放置元素,get()表示取元素。

     1 package TomTexts;
     2 
     3 public class TomTexts_15 {
     4       public static void main(String args[ ])
     5       { 
     6     int I,j;
     7     int intArray[]={30,1,-9,70,25};
     8     int l=intArray.length;
     9     for( I=0;I<l-1;I++)
    10       for( j=I+1;j<1;j++)
    11           if(intArray[I]>intArray[j])
    12            {int t=intArray[I];
    13             intArray[I]=intArray[j];
    14             intArray[j]=t;
    15            }
    16     for( I=0;I<l;I++)
    17     System.out.println(intArray[I]+ " ");
    18     }
    19 
    20 }
  • 相关阅读:
    工厂方法模式
    命名空间的规划
    Download Manager
    Intent(二)
    Intent (一)
    Fragment (一)
    修改环境变量需不需要重启电脑
    Spring mvc和SSH如何取舍?
    ORA-01795: 列表中的最大表达式数为1000的解决方法详解
    apache与tomcate的区别
  • 原文地址:https://www.cnblogs.com/borter/p/9420375.html
Copyright © 2020-2023  润新知