Going by the comment discussion as well as the fact that you copied the code and didn’t write it yourself, I am guessing that you are trying to run that raw block of code by itself and didn’t realize that it must go in some other code.
-
You must import the ArrayList and List.
-
Everything in Java must be in a class, with the name of the file matching the name of the class.
-
For your code to run from the console (which is presumably where you want to run it), it should be inside main.
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
int[] given_list = {0,4,5,56,3, 2000, 453, 5435};
// insert your code here
}
}
I’ve seen a lot of people try to copy their way through a programming course. The problem is, even small things like this will cripple you if you don’t know the basics. At least open the first few pages.
1
solved Given a list of integers, remove all values greater than 100