Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java - cannot find symbol - Class Arraylist

Tags:

java

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>();
    }
like image 416
robert Avatar asked Feb 11 '11 01:02

robert


People also ask

What to do if Cannot find symbol in Java?

Output. In the above program, "Cannot find symbol" error will occur because “sum” is not declared. In order to solve the error, we need to define “int sum = n1+n2” before using the variable sum.

How do you find the length of an ArrayList?

The size of an ArrayList can be obtained by using the java. util. ArrayList. size() method as it returns the number of elements in the ArrayList i.e. the size.


3 Answers

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*/
}
like image 157
Andre Pastore Avatar answered Nov 02 '22 15:11

Andre Pastore


capitalize the L in ArrayList.

like image 39
Scott M. Avatar answered Nov 02 '22 14:11

Scott M.


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.

like image 23
0bot Avatar answered Nov 02 '22 15:11

0bot