首页 > 编程知识 正文

java初始化map数组,java map集合

时间:2023-05-06 17:21:55 阅读:53557 作者:1203

/** *集合转换* eg : * liststringbase=new ArrayList (; *base.add('11; 12; 3 (); *base.add('21; 22; 3 (); *base.add('31; 22; 3 (); * varlist=转换列表(base,e-newinteger[]{integer.valueof ) e.split('[; ] ' ) [0] ),integer.valueof(e.split ) ([; ] ' ) [1],integer.valueof(e.split ) ([; () ) ) }; *for(varL:list ) ) system.err.println(L[0] )='L[1] )='L[2]; * * println :33603360 * 11=12=33 * 21=22=33 * 31=22=33 * /公共静态t,ulistuconvertlist (列表表单,) } RRR }/** *序列转换* eg: * String value='1; 2; 3 ); * varlist=转换阵列(value.split (' [; ()、Integer:valueOf、integer () :3360new ); *for(varL:list ) ) system.err.println ) l; * * println :33603360 *1*2*3* /公共静态t,uuu [ ]转换阵列(t [ ] from,FunctionT,U func,intfunction }/** *数组转换* eg : * list integer [ ] base=new ArrayList (; *for(intI=0; i 3; I () base.add(newinteger[] ) i * 100 1,i * 100 1,I*1002 ); **varlist=list2Array(base,e - e[0],Integer[]:new ); *for(varL:list ) ) system.err.println ) l; * * println :33603360 *0* 100 * 200 * /公共静态t,uu [ ] list 2阵列(list tfrom,FunctionT,U func,intfunction ) }/** * map转集* eg: * HashMapLong,Long tmp=new HashMap (; *tmp.put(1L,1l ); *tmp.put(2L,1l ); *tmp.put(3L,1l ); * varlist=转换列表(tmp,e - new Long[]{e.getKey ),e.getValue ) }; *for(varL:list ) ) system.err.println(L[0]'='L[1] ); * * println :33603360 *1=1*2=1*3=1* /公共静态k,v,ulistuconvertlist(mapk,V from,function map.funurtion }/** *将数组转换为map * eg : * list long [ ] base=new ArrayList (; *base.add(newlong[]{1L,1l}; *base.add(newlong[]{2L,2l}; *base.add(newlong[]{3L,3l}; * varmap=转换地图(base,e - e[0],e - e[1]; * var ite=map.entrySet ().iterator ); *while(ite.Hasnext () ) { * var e=ite.next ); *system.err.println(e.getkey () )=' e.getValue ); * * println :33603360 *1=1*2=2*3=3* /公共静态k、v、T MapK、vconvertmap (列表tfrom、FunctionT、kfuncttmap }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。