I have a map and trying to convert that to 2 dimension array. For this I am converting the values of Map to list and then trying to convert to 2 dimensional array.
My code is
try {
List list = new ArrayList(layoutMap.values());
int listSize = list.size();
ArrayList[][] layoutList = new ArrayList[listSize][];
for(int i = 0; i < listSize; i++){
List sublist = (ArrayList) list.get(i);
int subListSize = sublist.size();
layoutList[i] = new ArrayList[subListSize];
for (int j = 0; j < subListSize; j++) {
layoutList[i][j] = (ArrayList) sublist.get(j);
}
}
} catch (Exception e) {
log.error("@layoutMapDetails () :", e);
}
when i do this I am getting class cast exception com.pojo.layout.LayoutDetails cannot be cast to java.util.ArrayList
Is there any way to solve this. Is the conversion of List to 2-dimensional array right..? Here the layoutMap is Map<Integer, List>