10

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>();
    }
0

5 Answers 5

21

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*/
}
Sign up to request clarification or add additional context in comments.

Comments

12

capitalize the L in ArrayList.

Comments

5

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.

1 Comment

While that is certainly true, the case problem was mentioned three times in the previous responses, all dated over a year ago ;-)
4

It's ArrayList, not Arraylist. Case matters.

Comments

0

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

1 Comment

Please explain what additional insight this answer provides, especially in comparison to the older, upvoted answer by Andre Pastore. Discuss why importing less specifically is an advantage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.