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

Minor correction

parent 0fe655c6
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ import java.util.List; ...@@ -4,7 +4,7 @@ import java.util.List;
public class FixMe { public class FixMe {
public static void main(String[] args) { public static void main(String[] args) {
// Test the method with different inputs // Test the method with different inputs
ArrayList<Integer> list = new ArrayList<>(); ArrayList<Integer> list = new ArrayList<>;
list.add(1); list.add(1);
list.add(2); list.add(2);
list.add(-1); list.add(-1);
...@@ -15,7 +15,7 @@ public class FixMe { ...@@ -15,7 +15,7 @@ public class FixMe {
removeNegatives(list); removeNegatives(list);
System.out.println(list); System.out.println(list);
}
/** /**
* The method removes all elements smaller than zero from the list * The method removes all elements smaller than zero from the list
...@@ -23,10 +23,10 @@ public class FixMe { ...@@ -23,10 +23,10 @@ public class FixMe {
*/ */
public static void removeNegatives(ArrayList<Integer> list) { public static void removeNegatives(ArrayList<Integer> list) {
int index = 0; int index = 0;
while (index < list.size()) { while index < list.size() {
int element = list.get(index); int element = list.get(index);
if (element > 0) { if (element > 0) {
list.remove(index); list.remove(inde);
} else { } else {
index++; index++;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment