I have two lists and I want to make a list of lists. For some reason after I print out each list, I get a massive one entry in the array. I am using the data coming from a hash map, and need to split the key string to get the values back, then cast the integer to a string to add to array.
ArrayList<ArrayList<String>> listOLists = new ArrayList<ArrayList<String>>();
ArrayList<String> singleList = new ArrayList<String>();
for (Entry<String, Integer> entry : counts.entrySet()) {
String val = entry.getValue().toString();
List<String> key = Arrays.asList(entry.getKey().split("@"));
singleList.add(key.get(0));
singleList.add(key.get(1));
singleList.add(key.get(2));
singleList.add(val);
listOLists.add(singleList);
}
for(ArrayList<String> s: listOLists){
System.out.println(s);
}
I am getting:
[Demo-Site, 172.20.58.160, 2015-08-06, 12, Demo-Site, 10.227.145.103, 2015-08-19, 1, Demo-Site, 10.7.0.146, 2015-08-11, 3,
I want in the final output to look something like this:
[[Demo-site, 172.20.58.160, 2015-08-06, 12], [Demo-site, 10.227.145.103, 2015-08-19, 1]..etc]