From c1f9e01527c0f541d59529cd54bb2023e3c1c374 Mon Sep 17 00:00:00 2001 From: Juuso Rytilahti <rytilahti.juuso@gmail.com> Date: Thu, 21 Dec 2023 14:16:55 +0200 Subject: [PATCH] Minor correction --- codes/FixMe.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/codes/FixMe.java b/codes/FixMe.java index c30bae8..1a49b98 100644 --- a/codes/FixMe.java +++ b/codes/FixMe.java @@ -4,7 +4,7 @@ import java.util.List; public class FixMe { public static void main(String[] args) { // Test the method with different inputs - ArrayList<Integer> list = new ArrayList<>(); + ArrayList<Integer> list = new ArrayList<>; list.add(1); list.add(2); list.add(-1); @@ -15,7 +15,7 @@ public class FixMe { removeNegatives(list); System.out.println(list); - } + /** * The method removes all elements smaller than zero from the list @@ -23,13 +23,13 @@ public class FixMe { */ public static void removeNegatives(ArrayList<Integer> list) { int index = 0; - while (index < list.size()) { + while index < list.size() { int element = list.get(index); if (element > 0) { - list.remove(index); + list.remove(inde); } else { index++; } } } -} \ No newline at end of file +} -- GitLab