标签:io ar sp java for on bs cti ad
public class MyArrayTool { private Object items; private Collection collection; public void setItems(Object items) { //collection this.items = items; //list set if(items instanceof Collection){ collection = (Collection) items; } if(items instanceof Map){ Map map = (Map) items; collection = map.entrySet(); } if(items.getClass().isArray()){ collection = new ArrayList(); for(int i=0;i<Array.getLength(items);i++){ Object value = Array.get(items, i); collection.add(value); } } } public void test() { Iterator it = collection.iterator(); while(it.hasNext()){ Object value = it.next(); System.out.print("value::"+value); } } }
标签:io ar sp java for on bs cti ad
原文地址:http://my.oschina.net/u/936286/blog/350547