Make MySortedList compatible with Java 8

This commit is contained in:
Manuel Thalmann 2022-09-28 10:44:54 +02:00
parent 3f6493694c
commit bf793a8cea

View file

@ -16,12 +16,7 @@ public class MySortedList extends MyList {
int comparisonResult;
try {
if (item instanceof Comparable x &&
currentNode.getItem() instanceof Comparable y) {
comparisonResult = x.compareTo(y);
} else {
throw new UnsupportedOperationException();
}
comparisonResult = ((Comparable) item).compareTo((Comparable) currentNode.getItem());
} catch (Exception e) {
comparisonResult = 0;
}