Hey everyone. I am trying to finish up a lab for my first java class ever, and boy am I struggling. I am trying to convert a method of arrays over to an array list. And while it seems like it should be simple, for whatever reason I am struggling. Any help would be great. Here's the method I have to re-write into an array list:
Its usually cleaner to get the element you need from the list and store it to a local variable. Also helps you to avoid accessing the list multiple times. As said above, use the get() method of the list:
Also, check the if-condition...in the array example you're comparing to some value nextPos, while in the Arraylist part you compare to the list size.