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

Ausgedruckt am: 11.05.2024 um 00:05 Uhr

Mitglied: 149569
149569 08.12.2021 aktualisiert um 12:54:21 Uhr
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.