/*
 * http://stackoverflow.com/questions/8781022/is-an-array-an-object-in-java
 * In the Java programming language, arrays are objects (§4.3.1), are
 * dynamically created, and may be assigned to variables of type Object
 * (§4.3.2). All methods of class Object may be invoked on an array.
 */
/*
 * http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an-object-or-something-else-entirely
 * There is a class for every array type, so there's a class for int[], there's
 * a class for Foo[]. These classes are created by JVM. You can access them by
 * int[].class, Foo[].class. The direct super class of these classes are
 * Object.class
 * [...]
 * There are four kinds of reference types: class types (§8), interface types
 * (§9), type variables (§4.4), and array types (§10).
 */
/*
 * http://docs.oracle.com/javase/8/docs/api/
 * java.lang.reflect.Array 
 * The Array class provides static methods to dynamically create and access
 * Java arrays. [Not used usually.]
 */
public class AArrays {
    // Le llamo AArrays porque en la API ya existe java.util.Arrays
    public static void main(String[] args) {
        int[] arrayInts = {1, 2, 3};
        char[] arrayChars = {'H', 'o', 'l', 'a'};
        // char[] arrayChars2 = "Hola nois! :-)".toCharArray();
        int[] arrayInts2 = new int[5];
        arrayInts2[1] = 3;
        arrayInts2[3] = 1;
        System.out.print("arrayInts con for clasico: ");
        for (int i = 0; i < arrayInts.length; i++) {
            System.out.print(arrayInts[i] + ", ");
        }
        System.out.println();
        System.out.print("arrayInts con foreach: ");
        for (int n : arrayInts2) {
            System.out.print(n + ", ");
        }
        System.out.println();
        System.out.print("arrayChars: ");
        for (char c : arrayChars) {
            System.out.print("'" + c + "', ");
        }
        System.out.println();
        System.out.println(arrayInts);
        System.out.println(arrayChars);
        System.out.println(arrayChars + "!!!!!");
        System.out.print(arrayInts[-1]); // Exception!
        System.out.print(arrayInts[3]); // Exception!
    }
}
