Class List should be already imported

I’m trying to create a list in Java without doing all the list.add() insert-elements-one-by-one junk, so I declared my lists like so, importing the following:

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;

List<Integer> nm = Arrays.asList( 7, -1, 4, -3, 0, -6);

It just gives me this:

./src/main/java/Main.java:84: error: cannot find symbol
    List<Integer> nm = Arrays.asList( 7, -1, 4, -3, 0, -6);
    ^
  symbol:   class List
  location: class Main

Link- https://replit.com/@arn5891/ap-summer-stuff
I don’t know if I imported the wrong libraries, or if I’m not declaring the list right- this is pretty much what the example I looked up had.
I think there’s something in ToS about not helping people with schoolwork, but my assignment doesn’t require me to generate any working code; helping me fix this shouldn’t violate anything.

You haven’t imported Lists: import java.util.List;

2 Likes

Thanks, I think I can figure out the rest of the errors.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.