Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generic array creation error

camickrNov 19 2008 — edited Nov 21 2008
I have a method that returns a single "row" of data. I thought I could returns multiple rows of data by creating an Array or ArrayList. In both cases I get the "generic array creation" error message.
import java.util.*;
import javax.swing.table.*;

abstract class Row4TableModel<T> extends AbstractTableModel
{
	protected List<T> modelData;

	public T getRow(int row)
	{
		return modelData.get( row );
	}

	public T[] getRowsAsArray(int... rows)
	{
		T[] rowData = new T[rows.length];

		for (int i = 0; i < rows.length; i++)
		{
			rowData[i] = getRow(rows);
}

return rowData;
}

public List<T> getRowsAsList(int... rows)
{
ArrayList<T> rowData = new ArrayList<T>[rows.length];

for (int i = 0; i < rows.length; i++)
{
rowData.add( getRow(rows[i]) );
}

return rowData;
}
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 19 2008
Added on Nov 19 2008
6 comments
429 views