Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { private static List<Object[]> parseEntityData(final Iterator<Object[]> dataIterator, final Class<?>[] classes) throws Exception { List<Object[]> list = new ArrayList<Object[]>(); while (dataIterator.hasNext()) { Object[] rowDataArray = dataIterator.next(); List<Object> rowData = new ArrayList<Object>(); if (classes != null) { for (Object data : rowDataArray) { for (Class<?> clazz : classes) { if (data.getClass() == clazz) { rowData.add(data); } } } } list.add(rowData.toArray(new Object[] { rowData.size() })); } return list; } }