// Can you have an array of mixed types?
// No, not directly!

public class array_mixedtypes {

    public static void main(String args[]) {
	
	// The following attempts will NOT compile.
	// You CANNOT mix types inside an array
	//     int[]char[] a = new int[2]char[2];
	//     int[][] a = { {1, 2}, {"a", "b"} };
	
	// Note: There are some "ways around" the system.

	// Integer literals will promote to floating-point:
	System.out.println("Floating point:");
	double[] a = {1, 1.0};
	for(int i = 0; i <= a.length-1; i++)
	    System.out.println(a[i]);

	// Characters can be treated as character codes
	// update: there were some typos here
	// (see pg 589)
	// Java treats b[0] as integer 1
	// Java treats b[1] as the integer CODE for '1'
	System.out.println("Mixing integers and chars:");
	int[] b = {1,'1'};
	for(int i = 0; i <= b.length-1; i++)
	    System.out.println(b[i]);

    } // method main
    
} // class array_mixedtypes

/* Output:
Floating point:
1.0
1.0
Character codes:
1
49
*/
