ankitdixit
Goto Top

Query: The import java.util.ArrayList cannot be resolved Java

Hello All, I am facing some issues while I am trying to run this java program in vscode on online compiler but it shows an error on the 2nd line (The import java.util.ArrayList cannot be resolved Java(268435846)) and 6th line. But it gives correct output in an online compiler. Any suggestions?

import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
public class CollectionDemo {
    public static void main(String args) {
        ArrayList al = new ArrayList();
        al.add(100);
        al.add("String");  
        System.out.println(al);
    }
}

Content-Key: 1570919219

Url: https://administrator.de/contentid/1570919219

Printed on: April 24, 2024 at 20:04 o'clock

Mitglied: 149569
149569 Dec 08, 2021 updated at 11:54:21 (UTC)
Goto Top
This runs correctly in the online compiler
https://www.interviewbit.com/online-java-compiler/
same here
https://tio.run/##dY2xCoMwEEBn8xWHUxwa7CwdStdujqXD1YjEnokkp0WK325jBZfS6b ...
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
class main {
    public static void main(String args) {
       ArrayList al = new ArrayList();
       al.add(100);
       al.add("String");  
       System.out.println(al);
   }
}

screenshot

(The import java.util.ArrayList cannot be resolved Java(268435846))
If you get this error you do not have defined the correct java library for your project, or include pathes are faulty.