알 수없는 데이터 형식을 int
과 비교할 수 있습니까? 최대 노드를 가져 오는 함수를 작성하려고하지만 데이터 유형이 E가 아닌 int
입니다.comapre "알 수없는"값이있는 데이터
내 코드 지금까지 IS ..
public E getMax() {
if (isEmpty()) {
throw new NoSuchElementException(" error ") ;
} else {
Node n = first;
E x ;
int max = 0 ;
while (n!=null) {
if (n.data > x) {
max = n.data;
}
}
return x;
}
}
을'E Comparable가를 확장'다음'x.compareTo를 사용 (...)'를 사용하여 최대 값을 찾습니다. –
Supericy