In this tutorial, we will learn writing java program to create an array and perform left rotation on elements stored in the array by two positions.
That means if our array (list) is

After two left rotations

Java Program to Perform Left Rotation on Array Elements by Two
Output

Explanation
For the input array: [1, 2, 3, 4, 5], the for loop will rotate the array 2 times.
For 1st rotation the array becomes: [2, 3, 4, 5, 1].
And finally at 2nd rotation the array becomes: [3, 4, 5, 1, 2]