//CreatingArrays.java
//Illustrates various ways to create an array.

public class CreatingArrays
{
    public static void main(String[] args)
    {
        //Here's one way to create an array of integers.
        //Note that auto-boxing is in effect.
        Integer[] integers1 = new Integer[]
        {
            4, 1, 5, 3, 2
        };
        System.out.print("integers1: ");
        for (Integer i : integers1)
        {
            System.out.print(i + " ");
        }
        System.out.println();

        //Here's another (shorter) way (that creates the same array as above):
        //And again, auto-boxing is in effect.
        Integer[] integers2 =
        {
            4, 1, 5, 3, 2
        };
        System.out.print("integers2: ");
        for (int i : integers2)
        {
            System.out.print(i + " ");
        }
        System.out.println();

        //=============================================================
        //Now we repeat what we did in the above two code segments, but
        //this time with strings instead of integers:
        String strings1[] = new String[]
        {
            "klm", "abc", "xyz", "pqr"
        };
        System.out.print("strings1: ");
        for (String s : strings1)
        {
            System.out.print(s + " ");
        }
        System.out.println();

        String strings2[] =
        {
            "klm", "abc", "xyz", "pqr"
        };
        System.out.print("strings2: ");
        for (String s : strings2)
        {
            System.out.print(s + " ");
        }
        System.out.println();
    }
}
/*  Output:
    integers1: 4 1 5 3 2
    integers2: 4 1 5 3 2
    strings1: klm abc xyz pqr
    strings2: klm abc xyz pqr
*/

