1 .剪切1.list指定部分
列表子列表=new ArrayList (;
sublist=new ArrayList (a list.sublist (2,4 );
2 .在指定位置更新内容
publicarraylistattrs=new ArrayList (; //图层属性
attrs.set (位置,' string ';
判断阵列列表中是否有重复
publicstaticvoidmain (字符串[ ] args ) )。
{
列表列表=new ArrayList (;
list.add(aa );
list.add('bb );
list.add (抄送);
list.add(DD );
list.add('bb );
list.add(ee );
list.add(DD );
list.add('ff );
String temp=' ';
for(intI=0; Ilist.size(-1; I )
{
TEMP=list.get(I;
for(intj=I1; j list.size (; j )
{
if(temp.equals(list.get(j ) )
{
system.out.println('I1 ) '号和' (j 1 ) '号重复,值为(temp );
}
}
}
}
4.java中集合(list )和数组)的相互转换
1 )数组到集合的转换
数组可以转换为List,但不能使用显示功能以外的功能。 由于不知道转换生成的List是什么类型,因此可以通过生成集合的方法赋值来使用其他功能:
String[] names={ '刘备',' lsdch ',' dldds'};
列表列表1=arrays.as list (names );
列表1=new ArrayList (列表1;
2 )从集合到数组的转换
object [ ] ary1=list3. to array (new string [ list3. size (];
//system.out.println (arrays.tostring (ary1);
5 .混列映射被转换为阵列列表
hashmap hashmap=imarker service.getbaidumarkermap (;
ArrayList markers=new ArrayList (hashmap.values ();
6 .转换为字符串join
列表用户参数=new ArrayList (;
stringusersql=string.join('and ',userParms );
8 .排序
collections.sort(warnRES,new Comparator ) ) (()//保修终止日期
公共int比较(WarnRes warnRes1,WarnRes warnRes1) {
return warnRes1.getZbrq ().com Pareto (warn RES0. getz brq ) );
}
);