@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
@August 그건 배열 형식처럼 보입니다. –
어레이 유형입니다. – user2820406