Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        // create array list object
        List<Integer> numbers = new ArrayList<Integer>();

        // populate the list
        for (int i = 0; i < 15; i++) {
            numbers.add(i);
        }

        System.out.println("Before : " + Arrays.toString(numbers.toArray()));

        // rotate the list at distance 10
        Collections.rotate(numbers, 10);

        System.out.println("After : " + Arrays.toString(numbers.toArray()));
    }
}