Skip to content
Snippets Groups Projects
Commit c1f9e015 authored by Juuso Rytilahti's avatar Juuso Rytilahti
Browse files

Minor correction

parent 0fe655c6
Branches main
No related tags found
No related merge requests found
......@@ -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,10 +23,10 @@ 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++;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment