From a14dc0d889f4eda9132734cf455dd7df2606f79f Mon Sep 17 00:00:00 2001 From: Kamlesh Kumar Date: Sat, 29 Jun 2019 18:54:06 +0530 Subject: [PATCH] Updated the previous variable in loop (#7205) --- .../baeldung/algorithms/checksortedlist/SortedListChecker.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/checksortedlist/SortedListChecker.java b/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/checksortedlist/SortedListChecker.java index d2aa159e6d..ab6eb6bc14 100644 --- a/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/checksortedlist/SortedListChecker.java +++ b/algorithms-miscellaneous-3/src/main/java/com/baeldung/algorithms/checksortedlist/SortedListChecker.java @@ -27,6 +27,7 @@ public class SortedListChecker { if (previous.compareTo(current) > 0) { return false; } + previous = current; } return true; } @@ -43,6 +44,7 @@ public class SortedListChecker { if (employeeComparator.compare(previous, current) > 0) { return false; } + previous = current; } return true; }