简体   繁体   中英

how could I separate items in one cell of an arraylist?

Is there any way to separate items in one cell of an arraylist ? when I print my array list it looks like this :

[4485,8765,7665,76545,6544,66544,43332,2222 ....]
[8833,8383,38383,39595,49596,60696,50505,...]
.
.
.

so I think that it save many items in one cell while I want to save them separately. now how can I divide items in one cell and save them separately? ( the arraylist save packets received from udp )

Assuming your List is declared this way:

List<List<Integer>> list = new ArrayList<List<Integer>>();

You can simply iterate it.

for(List<Integer> integers : list) {
    System.out.println(integers);
}
public static void main(String args[])
{
    ArrayList<Integer> arr=new ArrayList<Integer>();
    arr.add(121);
    arr.add(122);
    arr.add(123);
    arr.add(124);
    arr.add(125);


    List<Integer> l=arr;
    for(int i=0;i<l.size();i++)
   {
    System.out.println(l.get(i));
   }


  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM