-3

I am trying to create a program in eclipse that uses an ArrayList. The problem I am having is that whenever I try and create a new list-

List<Integer> list = new ArrayList<>();

I get an error saying that I cannot use <> for source level below 1.7. I tried to fix it by just clicking on the error and changing the source level, but then I get an error when I try to run the program saying there is no main method.

Any help is appreciated. Thanks!

Jared
  • 578
  • 7
  • 21

2 Answers2

1

So your problem now is the main method. You've fixed the compilation error so now Eclipse is trying to run the program. Make sure you're actually trying to run a class with a main method, the class compiles, and the method's signature is correct. Each keyword is important, not just the name.

public static void main(String[] args) {

}
vempo
  • 3,093
  • 1
  • 14
  • 16
0

Here is a example of what you should write :

import java.util.ArrayList;
import java.util.List;

public class Test{
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
    }
}