首页 > 其他 > 详细

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

时间:2018-08-04 22:47:26      阅读:157      评论:0      收藏:0      [点我收藏+]

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 }

 

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

原文:https://www.cnblogs.com/borter/p/9420375.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!