Question: I want to be able to resize an ArrayList with any size I want using my method above main. Im using a try block so
I want to be able to resize an ArrayList with any size I want using my method above main. Im using a try block so that if I try to set an element out of range, it will resize the array first and then set the lement. How do I make this work?
Problems Task Console P Properties Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.base/java.util. Arrays.copyof (Arrays. java:3512) at java.base/java.util. Arrays. copyof (Arrays.java:3481) at java.base/java.util.ArrayList.grow (ArrayList.java:237) at java.base/java.util.ArrayList.grow (ArrayList.java:244) at java.base/java.util. ArrayList.add (ArrayList.java:454) at java.base/java.util. ArrayList.add (ArrayList.java:467) at testCode.Test.resizeArrayList (Test.java:10) at testCode. Test.main (Test. java:20)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
