Problem Description
-
Reference variable is stored in the address value of the object instance, if a variable direct printing, the output value should be the address.
-
The numeric array int array: direct printing the array name after initialization, the address value is outputted.
-
But: char type arrays, whether new or direct assignment initialization, not actually address values are displayed directly after printing, but the contents of the array.
Cause Analysis
-
an array of char is equivalent to a string.
-
Since the output stream is System.out PrintStream objects, there PrintStream method println plurality overloaded, one of which is public void println (char [] x), then directly printed character array, not int [] array other, it will directly call this method to print, so you can print out the contents of the array instead of the address.
tips:
-
String, it is not change its content.
-
An array of characters, you can change the contents of the array contains.
-
If the depth to say, the bottom of the string is an array implementation.
-
Difference used to say, convenient strings, arrays flexible.