숙제는 기본적으로 세트의 메소드를 다시 작성하여 Square
이라는 사용자 정의 클래스에 사용할 수 있습니다. 나는 오류가 계속 : 세트는 동일한 지우기가 있지만 아직 다른 오류를 무시하지 않습니다
error: name clash: removeAll(Collection<Square>) in SquareSet and removeAll(Collection<?>) in Set have the same erasure, yet neither overrides the other
public boolean removeAll(Collection<Square> objects) {
나는 내 코드의 시작과 클래스
SquareSet
구현
Set<Square>
에
Set
및
Collection
모두를 수입했다.
public boolean removeAll(Collection<Square> objects) {
Square[] newSet;
int count = 0;
for(Square each : objects) {
count -= 1;
newSet = new Square[(daSet.length)-count];
for (int i = 0; i < daSet.length; i++) {
if (daSet[i].equals(each)) {
if(i == 0) {
for (int j = 1; j < daSet.length ; j++) {
newSet[j - 1] = daSet[j];
}
} else if (i == ((daSet.length) - 1)) {
for (int j = 0; j < daSet.length ; j++) {
newSet[j] = daSet[j];
}
} else {
for (int j = 0; j < i; j++) {
newSet[j] = daSet[j];
}
for (int j = i; j < newSet.length; j++){
newSet[j] = daSet[j+1];
}
}
}
}
}
나는 매개 변수가 내가 덮어 쓰기있어 매개 변수 유형에서 다른 경우 방법 대신 덮어 쓰기의 과부하 이해합니다. 그러나 나는 왜 나는이 오류가 발생하는지 이해하지 못합니다. 당신이 Set<Square>
을 구현하고 있기 때문에