<h1>
<span class="link_title"><a href="/yangxiaojun9238/article/details/51500934">
JAVA 集合 List 分组的两种方法
</a></span>
</h1>
    <div class="article_manage clearfix">
<div class="article_r">
<span class="link_postdate">2016-05-25 19:25</span>
<span class="link_view" title="阅读次数">2243人阅读</span>
<span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(0)</span>
<span class="link_collect tracking-ad" data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle('JAVA+%e9%9b%86%e5%90%88+List+%e5%88%86%e7%bb%84%e7%9a%84%e4%b8%a4%e7%a7%8d%e6%96%b9%e6%b3%95','51500934');return false;" title="收藏" target="_blank">收藏</a></span>
<span class="link_report"> <a href="#report" onclick="javascript:report(51500934,2);return false;" title="举报">举报</a></span> </div>
</div>
<div class="embody" style="display:none" id="embody">
<span class="embody_t">本文章已收录于:</span>
<div class="embody_c" id="lib" value="{&quot;err&quot;:0,&quot;msg&quot;:&quot;ok&quot;,&quot;data&quot;:[]}"></div>
</div>
<style type="text/css">
.embody{
padding:10px 10px 10px;
margin:0 -20px;
border-bottom:solid 1px #ededed;
}
.embody_b{
margin:0 ;
padding:10px 0;
}
.embody .embody_t,.embody .embody_c{
display: inline-block;
margin-right:10px;
}
.embody_t{
font-size: 12px;
color:#999;
}
.embody_c{
font-size: 12px;
}
.embody_c img,.embody_c em{
display: inline-block;
vertical-align: middle;
}
.embody_c img{
width:30px;
height:30px;
}
.embody_c em{
margin: 0 20px 0 10px;
color:#333;
font-style: normal;
}
</style>
<script type="text/javascript">
$(function () {
try
{
var lib = eval("("+$("#lib").attr("value")+")");
var html = "";
if (lib.err == 0) {
$.each(lib.data, function (i) {
var obj = lib.data[i];
//html += '<img src="' + obj.logo + '"/>' + obj.name + "&nbsp;&nbsp;";
html += ' <a href="' + obj.url + '" target="_blank">';
html += ' <img src="' + obj.logo + '">';
html += ' <em><b>' + obj.name + '</b></em>';
html += ' </a>';
});
if (html != "") {
setTimeout(function () {
$("#lib").html(html);
$("#embody").show();
}, 100);
}
}
} catch (err)
{ } });
</script>
<div class="category clearfix">
<div class="category_l">
<img src="http://static.blog.csdn.net/images/category_icon.jpg">
<span>分类:</span>
</div>
<div class="category_r">
<label onclick="GetCategoryArticles('1088196','yangxiaojun9238','top','51500934');">
<span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_fenlei']);">JAVASE学习笔记<em>(22)</em></span>
<img class="arrow-down" src="http://static.blog.csdn.net/images/arrow_triangle _down.jpg" style="display:inline;">
<img class="arrow-up" src="http://static.blog.csdn.net/images/arrow_triangle_up.jpg" style="display:none;">
<div class="subItem">
<div class="subItem_t"><a href="http://blog.csdn.net/yangxiaojun9238/article/category/1088196" target="_blank">作者同类文章</a><i class="J_close">X</i></div>
<ul class="subItem_l" id="top_1088196">
</ul>
</div>
</label>
</div>
</div>
<script type="text/javascript" src="http://static.blog.csdn.net/scripts/category.js"></script>

从网上找了两种方法,效率差不多,这里贴出代码供大家参考

实体类Data

  1. public class Data {
  2. private Long id ;
  3. private Long courseId ;
  4. private String content ;
  5. public Long getId() {
  6. return id;
  7. }
  8. public Data setId(Long id) {
  9. this.id = id;
  10. return this ;
  11. }
  12. public Long getCourseId() {
  13. return courseId;
  14. }
  15. public Data setCourseId(Long courseId) {
  16. this.courseId = courseId;
  17. return this ;
  18. }
  19. public String getContent() {
  20. return content;
  21. }
  22. public Data setContent(String content) {
  23. this.content = content;
  24. return this ;
  25. }
  26. }
public class Data {
private Long id ;
private Long courseId ;
private String content ; public Long getId() {
return id;
} public Data setId(Long id) {
this.id = id;
return this ;
} public Long getCourseId() {
return courseId;
} public Data setCourseId(Long courseId) {
this.courseId = courseId;
return this ;
} public String getContent() {
return content;
} public Data setContent(String content) {
this.content = content;
return this ;
}

}

排序类

  1. <pre name="code" class="java">import java.lang.reflect.Method;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.HashMap;
  5. import java.util.Iterator;
  6. import java.util.List;
  7. import java.util.Map;
  8. import com.framework.util.ParamUtils;
  9. public class CommonUtils {
  10. /**
  11. * 分組依據接口,用于集合分組時,獲取分組依據
  12. *
  13. * @author ZhangLiKun
  14. * @title GroupBy
  15. * @date 2013-4-23
  16. */
  17. public interface GroupBy<T> {
  18. T groupby(Object obj);
  19. }
  20. /**
  21. *
  22. * @param colls
  23. * @param gb
  24. * @return
  25. */
  26. public static final <T extends Comparable<T>, D> Map<T, List<D>> group(Collection<D> colls, GroupBy<T> gb) {
  27. if (colls == null || colls.isEmpty()) {
  28. System.out.println("分組集合不能為空!");
  29. return null;
  30. }
  31. if (gb == null) {
  32. System.out.println("分組依據接口不能為Null!");
  33. return null;
  34. }
  35. Iterator<D> iter = colls.iterator();
  36. Map<T, List<D>> map = new HashMap<T, List<D>>();
  37. while (iter.hasNext()) {
  38. D d = iter.next();
  39. T t = gb.groupby(d);
  40. if (map.containsKey(t)) {
  41. map.get(t).add(d);
  42. } else {
  43. List<D> list = new ArrayList<D>();
  44. list.add(d);
  45. map.put(t, list);
  46. }
  47. }
  48. return map;
  49. }
  50. /**
  51. * 将List<V>按照V的methodName方法返回值(返回值必须为K类型)分组,合入到Map<K, List<V>>中<br>
  52. * 要保证入参的method必须为V的某一个有返回值的方法,并且该返回值必须为K类型
  53. *
  54. * @param list
  55. *            待分组的列表
  56. * @param map
  57. *            存放分组后的map
  58. * @param clazz
  59. *            泛型V的类型
  60. * @param methodName
  61. *            方法名
  62. */
  63. public static <K, V> void listGroup2Map(List<V> list, Map<K, List<V>> map, Class<V> clazz, String methodName) {
  64. // 入参非法行校验
  65. if (null == list || null == map || null == clazz || !ParamUtils.chkString(methodName)) {
  66. System.out.print("CommonUtils.listGroup2Map 入参错误,list:" + list + " ;map:" + map + " ;clazz:" + clazz + " ;methodName:" + methodName);
  67. return;
  68. }
  69. // 获取方法
  70. Method method = getMethodByName(clazz, methodName);
  71. // 非空判断
  72. if (null == method) {
  73. return;
  74. }
  75. // 正式分组
  76. listGroup2Map(list, map, method);
  77. }
  78. /**
  79. * 根据类和方法名,获取方法对象
  80. *
  81. * @param clazz
  82. * @param methodName
  83. * @return
  84. */
  85. public static Method getMethodByName(Class<?> clazz, String methodName) {
  86. Method method = null;
  87. // 入参不能为空
  88. if (null == clazz || !ParamUtils.chkString(methodName)) {
  89. System.out.print("CommonUtils.getMethodByName 入参错误,clazz:" + clazz + " ;methodName:" + methodName);
  90. return method;
  91. }
  92. try {
  93. method = clazz.getDeclaredMethod(methodName);
  94. } catch (Exception e) {
  95. System.out.print("类获取方法失败!");
  96. }
  97. return method;
  98. }
  99. /**
  100. * 将List<V>按照V的某个方法返回值(返回值必须为K类型)分组,合入到Map<K, List<V>>中<br>
  101. * 要保证入参的method必须为V的某一个有返回值的方法,并且该返回值必须为K类型
  102. *
  103. * @param list
  104. *            待分组的列表
  105. * @param map
  106. *            存放分组后的map
  107. * @param method
  108. *            方法
  109. */
  110. @SuppressWarnings("unchecked")
  111. public static <K, V> void listGroup2Map(List<V> list, Map<K, List<V>> map, Method method) {
  112. // 入参非法行校验
  113. if (null == list || null == map || null == method) {
  114. System.out.print("CommonUtils.listGroup2Map 入参错误,list:" + list + " ;map:" + map + " ;method:" + method);
  115. return;
  116. }
  117. try {
  118. // 开始分组
  119. Object key;
  120. List<V> listTmp;
  121. for (V val : list) {
  122. key = method.invoke(val);
  123. listTmp = map.get(key);
  124. if (null == listTmp) {
  125. listTmp = new ArrayList<V>();
  126. map.put((K) key, listTmp);
  127. }
  128. listTmp.add(val);
  129. }
  130. } catch (Exception e) {
  131. System.out.print("分组失败!");
  132. }
  133. }
  134. }
<pre name="code" class="java">import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import com.framework.util.ParamUtils; public class CommonUtils {
/**
* 分組依據接口,用于集合分組時,獲取分組依據
*
* @author ZhangLiKun
* @title GroupBy
* @date 2013-4-23
*/
public interface GroupBy&lt;T&gt; {
T groupby(Object obj);
} /**
*
* @param colls
* @param gb
* @return
*/
public static final &lt;T extends Comparable&lt;T&gt;, D&gt; Map&lt;T, List&lt;D&gt;&gt; group(Collection&lt;D&gt; colls, GroupBy&lt;T&gt; gb) {
if (colls == null || colls.isEmpty()) {
System.out.println("分組集合不能為空!");
return null;
}
if (gb == null) {
System.out.println("分組依據接口不能為Null!");
return null;
}
Iterator&lt;D&gt; iter = colls.iterator();
Map&lt;T, List&lt;D&gt;&gt; map = new HashMap&lt;T, List&lt;D&gt;&gt;();
while (iter.hasNext()) {
D d = iter.next();
T t = gb.groupby(d);
if (map.containsKey(t)) {
map.get(t).add(d);
} else {
List&lt;D&gt; list = new ArrayList&lt;D&gt;();
list.add(d);
map.put(t, list);
}
}
return map;
}
/**
* 将List&lt;V&gt;按照V的methodName方法返回值(返回值必须为K类型)分组,合入到Map&lt;K, List&lt;V&gt;&gt;中&lt;br&gt;
* 要保证入参的method必须为V的某一个有返回值的方法,并且该返回值必须为K类型
*
* @param list
* 待分组的列表
* @param map
* 存放分组后的map
* @param clazz
* 泛型V的类型
* @param methodName
* 方法名
*/
public static &lt;K, V&gt; void listGroup2Map(List&lt;V&gt; list, Map&lt;K, List&lt;V&gt;&gt; map, Class&lt;V&gt; clazz, String methodName) {
// 入参非法行校验
if (null == list || null == map || null == clazz || !ParamUtils.chkString(methodName)) {
System.out.print("CommonUtils.listGroup2Map 入参错误,list:" + list + " ;map:" + map + " ;clazz:" + clazz + " ;methodName:" + methodName);
return;
} // 获取方法
Method method = getMethodByName(clazz, methodName);
// 非空判断
if (null == method) {
return;
} // 正式分组
listGroup2Map(list, map, method);
}
/**
* 根据类和方法名,获取方法对象
*
* @param clazz
* @param methodName
* @return
*/
public static Method getMethodByName(Class&lt;?&gt; clazz, String methodName) {
Method method = null;
// 入参不能为空
if (null == clazz || !ParamUtils.chkString(methodName)) {
System.out.print("CommonUtils.getMethodByName 入参错误,clazz:" + clazz + " ;methodName:" + methodName);
return method;
} try {
method = clazz.getDeclaredMethod(methodName);
} catch (Exception e) {
System.out.print("类获取方法失败!");
} return method;
}
/**
* 将List&lt;V&gt;按照V的某个方法返回值(返回值必须为K类型)分组,合入到Map&lt;K, List&lt;V&gt;&gt;中&lt;br&gt;
* 要保证入参的method必须为V的某一个有返回值的方法,并且该返回值必须为K类型
*
* @param list
* 待分组的列表
* @param map
* 存放分组后的map
* @param method
* 方法
*/
@SuppressWarnings("unchecked")
public static &lt;K, V&gt; void listGroup2Map(List&lt;V&gt; list, Map&lt;K, List&lt;V&gt;&gt; map, Method method) {
// 入参非法行校验
if (null == list || null == map || null == method) {
System.out.print("CommonUtils.listGroup2Map 入参错误,list:" + list + " ;map:" + map + " ;method:" + method);
return;
} try {
// 开始分组
Object key;
List&lt;V&gt; listTmp;
for (V val : list) {
key = method.invoke(val);
listTmp = map.get(key);
if (null == listTmp) {
listTmp = new ArrayList&lt;V&gt;();
map.put((K) key, listTmp);
}
listTmp.add(val);
}
} catch (Exception e) {
System.out.print("分组失败!");
}
}

}


测试类

  1. import java.util.ArrayList;
  2. import java.util.LinkedHashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import com.framework.common.CommonUtils.GroupBy;
  6. public class Test {
  7. /**
  8. * @param args
  9. */
  10. public static void main(String[] args) {
  11. // 准备一个集合
  12. final int loop = 1000 * 1000;
  13. List<Data> list = new ArrayList<Data>(); // size=8 * loop
  14. for (int i = 0; i < loop; i++) {
  15. list.add(new Data().setId(1L).setCourseId(200010L).setContent("AAA"));
  16. list.add(new Data().setId(2L).setCourseId(200010L).setContent("BBB"));
  17. list.add(new Data().setId(3L).setCourseId(200011L).setContent("CCC"));
  18. list.add(new Data().setId(4L).setCourseId(200011L).setContent("DDD"));
  19. list.add(new Data().setId(5L).setCourseId(200010L).setContent("EEE"));
  20. list.add(new Data().setId(6L).setCourseId(200011L).setContent("FFF"));
  21. list.add(new Data().setId(7L).setCourseId(200010L).setContent("GGG"));
  22. list.add(new Data().setId(8L).setCourseId(200012L).setContent("HHH"));
  23. }
  24. // 进行分组 1
  25. long time = System.currentTimeMillis();
  26. Map<Long, List<Data>> map2 = new LinkedHashMap<Long, List<Data>>();
  27. CommonUtils.listGroup2Map(list, map2, Data.class, "getId");// 输入方法名
  28. long duration = System.currentTimeMillis() - time;
  29. System.out.println("分组一执行:" + duration + "毫秒!");
  30. // 分组二
  31. time = System.currentTimeMillis();
  32. Map<Long, List<Data>> map = CommonUtils.group(list, new GroupBy<Long>() {
  33. @Override
  34. public Long groupby(Object obj) {
  35. Data d = (Data) obj;
  36. return d.getCourseId(); // 分组依据为课程ID
  37. }
  38. });
  39. duration = System.currentTimeMillis() - time;
  40. System.out.println("分组二执行:" + duration + "毫秒!");
  41. }
  42. }
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import com.framework.common.CommonUtils.GroupBy; public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// 准备一个集合 final int loop = 1000 * 1000;
List&lt;Data&gt; list = new ArrayList&lt;Data&gt;(); // size=8 * loop
for (int i = 0; i &lt; loop; i++) {
list.add(new Data().setId(1L).setCourseId(200010L).setContent("AAA"));
list.add(new Data().setId(2L).setCourseId(200010L).setContent("BBB"));
list.add(new Data().setId(3L).setCourseId(200011L).setContent("CCC"));
list.add(new Data().setId(4L).setCourseId(200011L).setContent("DDD"));
list.add(new Data().setId(5L).setCourseId(200010L).setContent("EEE"));
list.add(new Data().setId(6L).setCourseId(200011L).setContent("FFF"));
list.add(new Data().setId(7L).setCourseId(200010L).setContent("GGG"));
list.add(new Data().setId(8L).setCourseId(200012L).setContent("HHH"));
}
// 进行分组 1
long time = System.currentTimeMillis();
Map&lt;Long, List&lt;Data&gt;&gt; map2 = new LinkedHashMap&lt;Long, List&lt;Data&gt;&gt;();
CommonUtils.listGroup2Map(list, map2, Data.class, "getId");// 输入方法名 long duration = System.currentTimeMillis() - time; System.out.println("分组一执行:" + duration + "毫秒!"); // 分组二
time = System.currentTimeMillis();
Map&lt;Long, List&lt;Data&gt;&gt; map = CommonUtils.group(list, new GroupBy&lt;Long&gt;() {
@Override
public Long groupby(Object obj) {
Data d = (Data) obj;
return d.getCourseId(); // 分组依据为课程ID
}
}); duration = System.currentTimeMillis() - time; System.out.println("分组二执行:" + duration + "毫秒!"); }

}


    <div id="digg" articleid="51500934">
<dl id="btnDigg" class="digg digg_disable" onclick="btndigga();"> <dt>顶</dt>
<dd>1</dd>
</dl> <dl id="btnBury" class="digg digg_disable" onclick="btnburya();"> <dt>踩</dt>
<dd>0</dd>
</dl> </div>
<div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank">&nbsp;</a> </div>
<div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank">&nbsp;</a></div>
<script type="text/javascript">
function btndigga() {
$(".tracking-ad[data-mod='popu_222'] a").click();
}
function btnburya() {
$(".tracking-ad[data-mod='popu_223'] a").click();
}
</script>
<div style="clear:both; height:10px;"></div>

    <div class="similar_article" style="">
<h4>我的同类文章</h4>
<div class="similar_c" style="margin:20px 0px 0px 0px">
<div class="similar_c_t">
<label class="similar_cur">
<span style="cursor:pointer" onclick="GetCategoryArticles('1088196','yangxiaojun9238','foot','51500934');">JAVASE学习笔记<em>(22)</em></span>
</label>
</div> <div class="similar_wrap tracking-ad" data-mod="popu_141" style="max-height:195px;">
<a href="http://blog.csdn.net" style="display:none" target="_blank">http://blog.csdn.net</a>
<ul class="similar_list fl"><li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/52234786" id="foot_aritcle_52234786undefined6286303496263972" target="_blank" title="Thumbnails操作图片发红的问题解决">Thumbnails操作图片发红的问题解决</a><span>2016-08-17</span><label><i>阅读</i><b>342</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/8493088" id="foot_aritcle_8493088undefined4650400583232628" target="_blank" title="jsonlib json,xml,object 互转">jsonlib json,xml,object 互转</a><span>2013-01-11</span><label><i>阅读</i><b>1839</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/8250601" id="foot_aritcle_8250601undefined2811853968223248" target="_blank" title="JAVA批量修改文本文件内容,支持子目录">JAVA批量修改文本文件内容,支持子目录</a><span>2012-12-03</span><label><i>阅读</i><b>3593</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/7337293" id="foot_aritcle_7337293undefined09073856205329212" target="_blank" title="java和oracle日期互转">java和oracle日期互转</a><span>2012-03-09</span><label><i>阅读</i><b>5933</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/7324817" id="foot_aritcle_7324817undefined2789552682571841" target="_blank" title="对BigDecimal常用方法的归类">对BigDecimal常用方法的归类</a><span>2012-03-06</span><label><i>阅读</i><b>233</b></label></li> </ul> <ul class="similar_list fr"><li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/10171861" id="foot_aritcle_10171861undefined8352417148090185" target="_blank" title="poi excel 多级联动">poi excel 多级联动</a><span>2013-08-22</span><label><i>阅读</i><b>1818</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/8488199" id="foot_aritcle_8488199undefined14007191595192148" target="_blank" title="java获得网页源代码">java获得网页源代码</a><span>2013-01-10</span><label><i>阅读</i><b>338</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/7349548" id="foot_aritcle_7349548undefined16425431161098203" target="_blank" title="properties配置文件操作实例">properties配置文件操作实例</a><span>2012-03-13</span><label><i>阅读</i><b>543</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/7336762" id="foot_aritcle_7336762undefined8513629169728651" target="_blank" title="java与oracle日期格式">java与oracle日期格式</a><span>2012-03-09</span><label><i>阅读</i><b>1471</b></label></li> <li><em>•</em><a href="http://blog.csdn.net/yangxiaojun9238/article/details/7312426" id="foot_aritcle_7312426undefined10967811199926958" target="_blank" title="日期转换">日期转换</a><span>2012-03-02</span><label><i>阅读</i><b>174</b></label></li> </ul>
<a href="http://blog.csdn.net/yangxiaojun9238/article/category/1088196" class="MoreArticle">更多文章</a></div>
</div>
</div>
<script type="text/javascript">
$(function () {
GetCategoryArticles('1088196', 'yangxiaojun9238','foot','51500934');
});
</script>
<div>
<div class="J_adv" data-view="true" data-mod="ad_popu_205" data-mtp="43" data-order="114" data-con="ad_content_1900" style="width: 728px; height: 90px;"><script src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-8990951720398508" data-ad-slot="8267689356/3776917242" data-adsbygoogle-status="done"><ins id="aswift_0_expand" style="display:inline-table;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent"><ins id="aswift_0_anchor" style="display:block;border:none;height:90px;margin:0;padding:0;position:relative;visibility:visible;width:728px;background-color:transparent"><iframe width="728" height="90" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&amp;&amp;s.handlers,h=H&amp;&amp;H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&amp;&amp;d&amp;&amp;(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_0" name="aswift_0" style="left:0;position:absolute;top:0;"></iframe></ins></ins></ins><script>(adsbygoogle=window.adsbygoogle || []).push({});</script></div>
</div>

.blog-ass-articl dd {
color: #369;
width: 99%; /*修改行*/
float: left;
overflow: hidden;
font: normal normal 12px/23px "SimSun";
height: 23px;
margin: 0;
padding: 0 0 0 10px;
margin-right: 30px;
background: url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;
}

参考知识库

Java SE知识库

22367关注|468收录

Java EE知识库

14983关注|1233收录

Java 知识库

22977关注|1441收录

软件测试知识库

3613关注|310收录

更多资料请参考:

 <dt><span>猜你在找</span></dt>    

<div id="adCollege" style="width: 42%;float: left;">
<script src="http://csdnimg.cn/jobreco/job_reco.js" type="text/javascript"></script>
<script type="text/javascript">
csdn.position.showEdu({
sourceType: "blog",
searchType: "detail",
searchKey: "51500934",
username: "",
recordcount: "5",
containerId: "adCollege" //容器DIV的id。
});
</script>
<div class="tracking-ad" data-mod="popu_84"><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/2981" title="java语言从入门到精通2016+项目实训" strategy="v4:content" target="_blank">java语言从入门到精通2016+项目实训</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/3767" title="JavaScript面向对象的编程视频课程第二季 对象" strategy="v4:content" target="_blank">JavaScript面向对象的编程视频课程第二季 对象</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/765" title="深入浅出Java的反射" strategy="v4:content" target="_blank">深入浅出Java的反射</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/3577" title="java核心技术精讲" strategy="v4:content" target="_blank">java核心技术精讲</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px; white-space: nowrap;"><a href="http://edu.csdn.net/course/detail/395" title="零基础学Java系列从入门到精通" strategy="v4:content" target="_blank">零基础学Java系列从入门到精通</a></dd></div></div> <div id="res" data-mod="popu_36" class="tracking-ad" style="width: 42%; float: left; margin-right: 30px; display: block;"><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/awj321000/article/details/25862015" title="HIBERNATE - 符合Java习惯的关系数据库持久化 Hibernate参考文档" strategy="SearchAlgorithm" target="_blank">HIBERNATE - 符合Java习惯的关系数据库持久化 Hibernate参考文档</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/guomei/article/details/46689569" title="Java 运行时监控第 3 部分 监控应用程序生态系统的性能与可用性" strategy="SearchAlgorithm" target="_blank">Java 运行时监控第 3 部分 监控应用程序生态系统的性能与可用性</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/u010185526/article/details/38229803" title="Java 运行时监控第 3 部分 监控应用程序生态系统的性能与可用性" strategy="SearchAlgorithm" target="_blank">Java 运行时监控第 3 部分 监控应用程序生态系统的性能与可用性</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/allenjay11/article/details/53331855" title="JAVA 笔记三 从源码深入浅出集合框架" strategy="SearchAlgorithm" target="_blank">JAVA 笔记三 从源码深入浅出集合框架</a></dd><dd style="background:url(http://static.blog.csdn.net/skin/default/images/blog-dot-red3.gif) no-repeat 0 10px;"><a href="http://blog.csdn.net/matry521/article/details/52210139" title="Java面试题整理" strategy="SearchAlgorithm" target="_blank">Java面试题整理</a></dd></div>
<div id="ad_cen">

<!-- 广告位开始 -->
<div class="J_adv" data-view="true" data-mod="ad_popu_72" data-mtp="62" data-order="40" data-con="ad_content_2072"><script id="popuLayer_js_q" src="http://ads.csdn.net/js/popuLayer.js" defer="" type="text/javascript"></script><div id="layerd" style="position: fixed; bottom: 0px; right: 0px; line-height: 0px; z-index: 1000; width: 300px; height: 278px; display: none;"><div class="J_close layer_close" style="display:;background-color:#efefef;padding:0px;color:#333;font:12px/24px Helvetica,Tahoma,Arial,sans-serif;text-align:right;">关闭</div><!-- 广告占位容器 --><div id="cpro_u2895327"><iframe id="iframeu2895327_0" src="http://pos.baidu.com/kcpm?rdid=2895327&amp;dc=3&amp;di=u2895327&amp;dri=0&amp;dis=0&amp;dai=1&amp;ps=908x1049&amp;dcb=___adblockplus&amp;dtm=HTML_POST&amp;dvi=0.0&amp;dci=-1&amp;dpt=none&amp;tsr=0&amp;tpr=1487658161699&amp;ti=JAVA%20%E9%9B%86%E5%90%88%20List%20%E5%88%86%E7%BB%84%E7%9A%84%E4%B8%A4%E7%A7%8D%E6%96%B9%E6%B3%95%20-%20yangxiaojun9238%E7%9A%84%E4%B8%93%E6%A0%8F%20-%20%E5%8D%9A%E5%AE%A2%E9%A2%91%E9%81%93%20-%20CSDN.NET&amp;ari=2&amp;dbv=2&amp;drs=3&amp;pcs=1349x662&amp;pss=1349x6895&amp;cfv=0&amp;cpl=5&amp;chi=1&amp;cce=true&amp;cec=UTF-8&amp;tlm=1487658161&amp;rw=662&amp;ltu=http%3A%2F%2Fblog.csdn.net%2Fyangxiaojun9238%2Farticle%2Fdetails%2F51500934&amp;ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DpC3Lxw1Xt3JfbmAMHgh7oVjYwzMUN9sFs1ZAaQycQmmyj-D8goMg9RmG5vmVZoWnRA2o6P11em6uAlmJh6nid5-l3_Y_9X_WjZ1eejC6aSi%26wd%3D%26eqid%3De542833a000555170000000358abbc5c&amp;ecd=1&amp;par=1366x768&amp;pis=-1x-1&amp;ccd=24&amp;cja=false&amp;cmi=7&amp;col=zh-CN&amp;cdo=-1&amp;sr=1366x768&amp;tcn=1487658162&amp;qn=b497df28aa28c99d&amp;tt=1487658161683.20.21.24" width="300" height="250" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" style="border:0; vertical-align:bottom;margin:0;" allowtransparency="true"></iframe></div></div><script> document.getElementById('popuLayer_js_q').onload=function(){ var styObjd=styObj={width:'300px','height':parseInt(250)+28};window.CSDN.Layer.PopuLayer('#layerd',{storageName:'layerd',styleObj:styObjd,total:50,expoire:1000*60}); }</script><!-- 投放代码 --><script type="text/javascript"> /*服务器频道首页置顶Banner960*90,创建于2014-7-3*/ (window.cproArray = window.cproArray || []).push({ id: 'u2895327' }); </script> <script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script></div>
<!-- 广告位结束 -->
查看评论

  暂无评论

您还没有登录,请[登录][注册]
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
<div id="ad_bot">
</div>
    <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
<img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复">
</a>
<a id="d-top-a" class="btn btn-top backtop" style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])">
<img src="http://static.blog.csdn.net/images/top.png" alt="TOP">
</a>

.tag_list
{
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid #D7CBC1;
color: #000000;
font-size: 12px;
line-height: 20px;
list-style: none outside none;
margin: 10px 2% 0 1%;
padding: 1px;
}
.tag_list h5
{
background: none repeat scroll 0 0 #E0DBD3;
color: #47381C;
font-size: 12px;
height: 24px;
line-height: 24px;
padding: 0 5px;
margin: 0;
}
.tag_list h5 a
{
color: #47381C;
}
.classify
{
margin: 10px 0;
padding: 4px 12px 8px;
}
.classify a
{
margin-right: 20px;
white-space: nowrap;
}

JAVA 集合 List 分组的两种方法的更多相关文章

  1. java字符串大小写转换的两种方法

    转载自:飞扬青春sina blogjava字符串大小写转换的两种方法 import java.io..* public class convertToPrintString {          pu ...

  2. java集合进行排序的两种方式

    java集合的工具类Collections中提供了两种排序的方法,分别是: Collections.sort(List list) Collections.sort(List list,Compara ...

  3. List集合序列排序的两种方法

    首先讲一下Comparable接口和Comparator接口,以及他们之间的差异.有助于Collections.sort()方法的使用.请参考 1.Comparable自然规则排序//在自定义类Stu ...

  4. java连接Access数据库的两种方法

    where ziduan  in(select  ziduan from  table) 嵌套 ResultSet rs = pst.executeQuery();List list = new Ar ...

  5. Java获得键盘输入的两种方法

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import ...

  6. Java获取当前类名的两种方法

    适用于非静态方法:this.getClass().getName() 适用于静态方法:Thread.currentThread().getStackTrace()[1].getClassName() ...

  7. Java中HashMap遍历的两种方法(转)

    第一种: Map map = new HashMap(); Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Ma ...

  8. Java导出Excel文件的两种方法

    将数据以Excel表格的形式导出:首先下载poi的jar包,导入项目中,或者使用maven仓库管理,在pom文件添加:<dependency>    <groupId>org. ...

  9. Java遍历文件夹的两种方法(非递归和递归)

    import java.io.File; import java.util.LinkedList; public class FileSystem {    public static int num ...

随机推荐

  1. ENTRYPOINT与CMD/实现切换用户执行

    1.CMD 最终会被解析成:["cmd","arg1","arg2"] 可以在运行时被覆盖 2.ENTRYPOINT 最终解析成 [&quo ...

  2. ANSYS 瞬态热分析--样件加热

    目录 1. 要求 2. ANSYS有限元分析 2.1 APDL建模 1. 要求 一块0.8m*0.4m*0.2m厚的钢板,在300℃的炉子中进行加热,其材料参数如下表所示: 材料参数 序号 名称 参数 ...

  3. 深度学习之父低调开源 CapsNet,欲取代 CNN

    “卷积神经网络(CNN)的时代已经过去了!” ——Geoffrey Hinton 酝酿许久,深度学习之父Geoffrey Hinton在10月份发表了备受瞩目的Capsule Networks(Cap ...

  4. mysql 官方读写分离方案

    mysql 8.0 集群模式下的自动读写分离方案 问题 多主模式下的组复制,看起来挺好,起始问题和限制很多.而且中断一个复制就无法配置了 多主模式下,innodbcluster 等于是无用的,不需要自 ...

  5. nginx windows下重新加载配置

    运行过程中,有个节点部分服务出现故障,像将其下线修复, 使用nginx -t; nginx -s reload 重新加载配置 得到错误"nginx: [error] OpenEvent(&q ...

  6. 理解WPF中的视觉树和逻辑树

    轉載地址:http://blog.csdn.net/changtianshuiyue/article/details/26981797 理解WPF中的视觉树和逻辑树  Understanding th ...

  7. Java笔记---成员初始化

    成员初始化 成员初始化 Java尽力保证所有变量可以在使用前可以初始化. void f(){ int i; System.out.println(i); //! i++; //开幕雷击:这里就报错了, ...

  8. 「快学springboot」集成Spring Security实现鉴权功能

    Spring Security介绍 Spring Security是Spring全家桶中的处理身份和权限问题的一员.Spring Security可以根据使用者的需要定制相关的角色身份和身份所具有的权 ...

  9. P1029最大公约数和最小公倍数

    P1029最大公约数和最小公倍数 #include <iostream> #include <cmath> #include <algorithm> #define ...

  10. 十三 Struts2复杂类型的数据封装,List封装和Map封装

    在实际开发当中,有可能遇到批量向数据库中插入记录,需要在页面中将数据封装到集合中.类似页面表达式方法 List封装: 前端JSP: <%@ page language="java&qu ...