From bf793a8cea8350c4e30397b664f76599c90058b3 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 28 Sep 2022 10:44:54 +0200 Subject: [PATCH] Make `MySortedList` compatible with Java 8 --- app/src/main/java/ch/nuth/zhaw/exbox/MySortedList.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/MySortedList.java b/app/src/main/java/ch/nuth/zhaw/exbox/MySortedList.java index ec4cdd1..0d6839a 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/MySortedList.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/MySortedList.java @@ -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; }