You're working with the two lists: LinkedList and ArrayList filled with String elements. You need to implement the changeHeadsAndTails method that should change the beginnings and the ends of the lists, so that:
- the first element of the
ArrayListwill become the first element of theLinkedListand vice versa; - the last element of the
ArrayListwill become the last element of theLinkedListand vice versa.
The example illustrates the idea:
// original lists
LinkedList [f, b, c, d, j]
ArrayList [a, g, h, i, e]
//after the changeHeadsAndTails method invocation
LinkedList [a, b, c, d, e]
ArrayList [f, g, h, i, j]