This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.