请各位大佬指点!JAVA中的集合如何遍历?

比如有5个list:listA={a,b,c}listB={d,e,f}listc={x,y,z,k,l}listc={1,2}listc={8,9,0,5}要将几个list的内容进行组合,结果为{adx18},{bey29},{efz0},{k5},{l}依次类推,实际情况可能会有更多的list,list里元素也会更多
月关宝盒
浏览 134回答 2
2回答

拉风的咖菲猫

packagecom.ui;importjava.util.ArrayList;importjava.util.Arrays;importjava.util.List;publicclassIter{publicstaticintgetMaxSize(Listlist){if(null==list||list.size()max){max=cur.size();}}returnmax;}publicstaticvoidmain(String[]args){Lista=newArrayList(Arrays.asList(newString[]{"a","b","c"}));Listb=newArrayList(Arrays.asList(newString[]{"d","e","f"}));Listc=newArrayList(Arrays.asList(newString[]{"x","y","z","k","l"}));Listd=newArrayList(Arrays.asList(newString[]{"1","2"}));Liste=newArrayList(Arrays.asList(newString[]{"8","9","0","5"}));ListgroupList=newArrayList();groupList.add(a);groupList.add(b);groupList.add(c);groupList.add(d);groupList.add(e);intindex=getMaxSize(groupList);for(inti=0;ii){builder.append(group.get(i));}}System.out.println(builder.toString());}}}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript