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

public class ArrayToArrList
{
    public static void main(String[] args)
    {
        String[] myArray = {"red", "green", "blue"};

        // *******************************************
        // Method1 to convert  array --> ArrayList
        ArrayList<String> myList1;

        // Instantiate ArrayList using an array 
        // (need to convert to a list first)
        myList1 = new ArrayList<>( Arrays.asList(myArray) );

        System.out.println( "myList1 = " + myList1 );
        
        // *******************************************
        // Method2 to convert  array --> ArrayList
        ArrayList<String> myList2 = new ArrayList<>();
        
        // Add elements in myArray to myList
        for (int i = 0; i < myArray.length; i++) 
            myList2.add( myArray[i] );

        System.out.println( "myList2 = " + myList2 );
    } 

}
