payasdoshi
payasdoshi

Reputation: 1

ArrayList cannot be resolved to a type : What is error in this code?

I was creating an ArrayList, and i am getting following error Exception in thread "main" java.lang.Error: Unresolved compilation problem: ArrayList cannot be resolved to a type Please help.

package learnCoreJava;

import java.util.List;

public class ArrayListDemo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        // Always initialize the concrete implementation with the interface types
                List<Integer> arrayList = new ArrayList<>(5);
                
                for(int i=0;i<=5;i++)
                    arrayList.add(i);
                
                System.out.println(arrayList);
    }

}

Upvotes: 0

Views: 2314

Answers (1)

Priyanshu
Priyanshu

Reputation: 121

Add this import statement :-

import java.util.ArrayList;

Upvotes: 2

Related Questions