Monday, March 30, 2009

Concatenate arrays to a List

This is a simple code snippet which explains, how to concatenate two arrays
into a list

private List getChildren(ContextNode parentItem) {
List siblings = null;
siblings = new ArrayList();
Collections.addAll(siblings, ((ContextNode)parentItem).getChildNodes());
Collections.addAll(siblings, ((ContextNode)parentItem).getAttributes());
return siblings;
}

Labels:

Convert HashMap to an array
Map aMap = new HashMap (  ) ; 
aList = new ArrayList ( aMap.values ( ) ) ;
aMap.clear ( ) ;

Labels: