Trying to wrap up a project. Everything works in it except it can't instantiate the animal into the designated array. This line is code that my instructor gave me, so I'm at even more of a loss. This is what I used to declare the array list:
private static ArrayList<Dog> dogList = new ArrayList<Dog>();
I then collect the information I needed and use the code below to try and add it to the array list. nthDog is a previously declared variable and the parameters are correct.
Dog nthDog = new Dog(name, breed, gender, age, weight, acquisitionDate,
acquisitionCountry, trainingStatus, reserved, inServiceCountry);
dogList.add(nthDog);
This code was sent to me by my instructor, however, when used it pulls up the errors ConcurrentModificationException and checkForComodification. Can't figure out what could be wrong.
dogListis used, or more context around theaddcall.dogListwhile iterating over it?ConcurrentModificationExceptionrequires there to be anIterator, either explicitly or implicitly e.g. with a for-each loop or a copy constructor. Please can you show the code doing the iterating?