As the title says, if I'm creating a method to remove a section of an ArrayList, how would I go about this.
If I have ArrayList<Character> se = {'a','b','c','d','e','f','g'}
and want to return only "abg"
I would call this method as such:
remove(2,5);
How could I create this method to remove not only the arg indexes but also everything in between?
list.subList(2, 6).clear()
does the job in one step.
Create a loop counting backward from 5 to 2 and remove the elements.
for(int i = 5; i >= 2; i--) ...
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