// Print.java
import java.util.Arrays;

class Print {

   public static void main (String[] args) {

      final char [] ca = { 'H', 'e', 'l',  'l', 'o'};
      final int [] ia = {1,2,3,4,5,6};

      /*
	"System.out" is an instance of "java.io.PrintStream".  The
	class "PrintStream" has the overloaded method "println" that
	works on types "String" and "char []".
      */
      System.out.println (ca);   // prints: "hello"

      /*
	Arrays, be they char[] or int[] or whatever, do not have a
	string conversion other than the default type/location value.
	The following line prints something like "Char array:  [C@7bed1c1f"
      */
      System.out.println ("Char array:  " + ca);
      System.out.println ("Char array:  " + ca.toString());

      /*
	Try this instead:
      */
      System.out.println ("Char array:  " + new String (ca));
      System.out.println ("Char array:  " + Arrays.toString(ca));  // new in 1.5

      /*
	Since no version of "println" exists for "int []", the
        "PrintStream.println (Object)" method is used which relies on the
        static "String.valueOf(Object)" method and since the object is not
	null this results in the string conversion "toString()" method being
	called.  For arrays this results in just the type/location value.

	All of the following are the same, and there was no easy way to get a
        more 'friendly' version until Java 1.5.
      */
      System.out.println (ia);
      System.out.println (String.valueOf(ia));
      System.out.println (ia.toString());
      System.out.println (Arrays.toString(ia));

      /*
	For arrays of objects ...
      */
      System.out.println (args);
      System.out.println (Arrays.asList (args));
      System.out.println (Arrays.toString (args));
   }

}