Extracting an How to ArrayList from an ArrayList and convert to int??
Hi,
I have a method which creates ArrayLists and stores them within an ArrayList as follows:
Code :
ArrayList<ArrayList<Integer>> clusters = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> set = new ArrayList<Integer>();
set.add(supportTemp); // supportTemp is an int
clusters.add(set);
I know clusters.get(0) will return the first "set" which was added, but i'd like to then convert this to an integer array. I've tried various methods from googling and reading the API, but am completely stuck on this. Any help would be appreciated.
Re: Extracting an How to ArrayList from an ArrayList and convert to int??
Done it, here's how...
Code :
ArrayList set = new ArrayList();
List newList = lists.get(0);
set.add(newList);
Object[] predators = newList.toArray();
Integer objectInteger = (Integer) predators[0];
int test = objectInteger.intValue();
System.out.println("Pred: " + test);
Re: Extracting an How to ArrayList from an ArrayList and convert to int??
Glad you worked it out :D
// Json