java array traversal in circular manner
I have an array which have 1 2 3 4 5 values. array a = [ 1 , 2, 3, 4, 5] Now i want to traverse it in circular manner. like i want to print 2 3 4 5 1 or 3 4 5 1 2 or 5 1 2 3 4 and so on. any algorithm on this? Edit: I want to print all the combination in circular manner. i don't want to state starting point at its initial phase. int start = ... for (int i = 0; i < a.length; i++) { System.out.println(a[(start + i) % a.length]); } (If you want to iterate the array backwards from start , change start + i to start - i in the array subscript expression.) I should note that this is probably not the