# 8.10. Code Practice with ArrayLists¶

Fix the following code so that it compiles. The code should instantiate an ArrayList of Strings names and fill it with the Strings from the array friends. It should then print out names.

In line 2, capitalize the l in Arraylist so that the proper library is imported. In line 10, change the terminating condition to i < friends.length so that you don’t go out of bounds of the array.

Fix the following class so that it will compile and the method reverse will return an ArrayList containing Integers in the reversed order of the ArrayList parameter list. Hint: for this solution, only one line needs to be added to the for-loop inside of the reverse method.

Fix the following method printEvenIndex so that it will print out the Integers at even indices of the passed-in ArrayList list.

Fix the following method printEvenElements so that it will print out all of the even Integers that are in the passed-in ArrayList list.

Rewrite the following code so that it fills the ArrayList values with the elements of the array nums using a for-each loop instead of a for loop.

Finish the following method sumNegVal to return the sum of all of the negative numbers in the ArrayList list, the parameter.

Finish the following method ‘’removeLongStrings’’ that checks each element of the passed in ArrayList list and removes any that are strictly longer than 4 characters.

Fill in the method shiftLeftOne below to shift all of the elements of the passed-in ArrayList list left by one. The original first element should be wrapped to the back of the list after the shift. Ex: {1, 2, 3, 4} should turn turn into {2, 3, 4, 1}

Finish the method moveSmallest so that it finds the smallest value in the passed-in ArrayList list and moves it to the front of the list.

Finish the method findLongest to find and return the longest String in the ArrayList of Strings list.