I have written the code and when I try to execute, it is giving error ArrayList does not take parameters. I have checked the code multiple times but unable to find any issue with it since I have my class name different than ArrayList.
class TestJavaCollection1
{
public static void main(String args[])
{
ArrayList list = new ArrayList();
list.add("Ravi");//Adding object in arraylist
list.add("Vijay");
list.add("Ravi");
list.add("Ajay");
Iterator itr = list.iterator();
while (itr.hasNext())
{
System.out.println(itr.next());
}
}
}