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 an array of string objs
        String init[] = { "One", "Two", "Three", "One", "Two", "Three", "from java2s.com" };

        // create one list
        List<String> list = new ArrayList<String>(Arrays.asList(init));

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

        // create singleton list
        list = Collections.singletonList("One");

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