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>();
}
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.
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.
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*/
}
capitalize the L in ArrayList.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With