Collection Rotate
# Java Example - Rotate Elements in a List
[ Java Example](#)
The following example demonstrates how to use the `rotate()` method of the `Collections` class to rotate elements in a list. The second parameter of the method specifies the starting position for the rotation:
## Main.java File
```java
import java.util.*;
public class Main {
public static void main(String[] args) {
List list = Arrays.asList("one Two three Four five six".split(" "));
System.out.println("List :" + list);
Collections.rotate(list, 3);
System.out.println("rotate: " + list);
}
}
The output of the above code is:
List :[one, Two, three, Four, five, six]
rotate: [Four, five, six, one, Two, three]
[ Java Example](#)
---
## 1 Note
1. #0 Bada
756***768@qq.com [](#)3 For a `List
YouTip