My contract ended a few weeks ago. I got rid of a bunch of tasks and have been learning
Java again.
I'm creating an ArrayList in the main() method. It is in Class Elementy. I'll want to have less code in main so I'll move the contents to a different class later on.
The ArrayList has mostly Ford brand automobiles. I pass the array to Class FordOnly.
In FordOnly I am attempting to remove elements that are not other brands of automobiles.
I mention lambda's in one of the comments but, I won't try that until I get this code working this way.
I'm getting an error message in the console. I don't know what is wrong. Here is the code and also the error messages:
"C:\Program Files\Java\jdk-17\bin\java.exe" -Didea.launcher.port=61071 "-Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\study\Java study\JCL_Update\out\production\JCL_Update;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMainV2 aRaise.Elementy
[Mustang, Volkswagen, Bronco, Chrysler, Taurus, Skylark, Explorer, Skylark, Expedition, Chrysler, Maverick, Volkswagen, Ranger]
Mustang
Volkswagen
Exception in
thread "main" java.util.ConcurrentModificationException
at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013)
at java.base/java.util.ArrayList$Itr.next(ArrayList.java:967)
at aRaise.FordOnly.processArray(FordOnly.java:22)
at aRaise.Elementy.main(Elementy.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Process finished with exit code 1