Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Rotate a List in Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Demo {
	public static void main(String args[]) {
		List<Integer>list = new ArrayList<Integer>();
		list.add(5);
		list.add(10);
		list.add(15);
		list.add(20);
		list.add(25);
		list.add(30);
		list.add(35);
		list.add(40);
		list.add(45);
		System.out.println("Initial list = "+list);
		Collections.reverse(list);
		System.out.println("List after rotation = "+list);
	}
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.