Archives: Collections

Java – Convert Array to Map using Commons ArrayUtils

This example use the Apache Commons lang’s ArrayUtils class to convert a two dimensional array to a Map object.



Java – Rotate Elements of List

Following example uses rotate() method to rotate elements of the list depending on the 2nd argument of the method.

Output:

List :[one, Two, three, Four, five, six]
rotate: [Four, five, six, one, Two, three]


Java – Convert Array to List

Output:

How many elements you want to add to the array:
red white green

red white green