robert
robert

Reputation: 135

java - cannot find symbol - Class Arraylist

I keep getting the following error with my arraylist. Any help is appreciated

cannot find symbol - Class Arraylist

public class Bank
{
    private ArrayList<Account> accounts;


    /**
     * A bank starts without any accounts.
     */
    public Bank()
    {
    accounts = new Arraylist<Account>();
    }

Upvotes: 10

Views: 48464

Answers (5)

Andre Pastore
Andre Pastore

Reputation: 2897

You need to add import declarations on class file header.

ArrayList is member of java.util package.

And, remember that Java is a case sensitive language. ArrayList is different from Arraylist

You should declare like following:

import java.util.ArrayList;

class Bank{
/*class content*/
}

Upvotes: 21

felix
felix

Reputation: 1

Please add the line import java.util.* in header.

Upvotes: 0

0bot
0bot

Reputation: 149

Java is case-sensitive. I think the problem is in this line:

accounts = new Arraylist();

It's "ArrayList" not Arraylist.

I hope to have been helpfull.

Upvotes: 5

Paul Tomblin
Paul Tomblin

Reputation: 182792

It's ArrayList, not Arraylist. Case matters.

Upvotes: 4

Scott M.
Scott M.

Reputation: 7347

capitalize the L in ArrayList.

Upvotes: 12

Related Questions