Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("J");
        list.add("R");
        list.add("C");
        list.add("X");

        System.out.println("List: " + list);

        // Uses Comparable implementation in String class
        // to sort the list in natural order
        Collections.sort(list);
        System.out.println("Sorted List:  " + list);

    }
}