java - Have complication with ArrayList of ArrayList -
i implementing algorithm,for need use arraylist
of arraylist
.i want retrieve each arraylist
main arraylist
.
eg: if main arraylist
contains 5 arraylist
, each arraylist
in main list contains 5 rows.
mainarraylist
:
[1,2,3,4,5,a , 2,3,4,5,3,b , 7,8,9,4,5,d] //1st arraylist [1,2,3,4,5,e , 2,3,4,5,3,n , 7,8,9,4,5,e] //11nd arraylist [1,2,3,4,5,f , 2,3,4,5,3,t , 7,8,9,4,5,q] //111rd arraylist [1,2,3,4,5,c , 2,3,4,5,3,b , 7,8,9,4,5,a] //1vth arraylist [1,2,3,4,5,r , 2,3,4,5,3,m , 7,8,9,4,5,z] //v th arraylist
i need access each arraylist
main list , print it's content row row i.e example print 1st arraylist
main list.
1,2,3,4,5,a 2,3,4,5,3,b 7,8,9,4,5,d
similarly need print arraylist in main list same above.
you can using arraylist
list<list<object>> twodimarray = new arraylist<arraylist<>>(); twodimarray.add(arrays.aslist("1","2","3"); for(list<object> list: twodimarray){ for(object o : list){ system.out.println(o.tostring()); } }
and of course using hashmap:
map<string,list<object>> map = new hashmap<string,list<object>>(); (map.entry<string, string> entry : map.entryset()) { system.out.println(entry.getkey() + "/" + entry.getvalue()); }
Comments
Post a Comment