我在这个代码块具有标识符预期的错误:标识符预期误差哈希表
@SuppressWarnings({"rawtypes","unchecked"})
theLists = new List<AnyType>[ nextPrime(2 * theLists.length) ];
for(int j = 0; j < theLists.length; j++)
theLists[ j ] = new LinkedList<>();
编译器说后“theLists”和=前应该有一个标识符。什么标识符?我该如何解决?
这是完整的方法:
private void rehash()
{
List<AnyType> [ ] oldLists = theLists;
// Create new double-sized, empty table
@SuppressWarnings({"rawtypes","unchecked"})
theLists = new List<AnyType>[ nextPrime(2 * theLists.length) ];
for(int j = 0; j < theLists.length; j++)
theLists[ j ] = new LinkedList<>();
// Copy table over
currentSize = 0;
for(List<AnyType> list : oldLists)
for(AnyType item : list)
insert(item);
}
我删除从身体的禁止警告,只是把它的构造,但它仍说标识符预期:
public HashTable(int size)
{
@SuppressWarnings("unchecked") theLists = (List<AnyType>[]) new List<?>[nextPrime(2 * theLists.length)];
for(int i = 0; i < theLists.length; i++)
theLists[ i ] = new ArrayList<>();
}
不能使用非数组类型括号标记。另外,'List'不能被实例化。 – August 2014-12-02 01:32:39
@八月这看起来像一个数组类型。 – 2014-12-02 01:35:14
这是一个数组类型。 – user2820406 2014-12-02 01:37:15