Home > Back-end >  The question of character array output
The question of character array output

Time:09-21

Public static void main (String [] args) {
Char [] ch={' H ', 'e', 'l', 'l', 'o'};
System. The out. Println (ch);
Char [] chars={' H ', 'E', 'L', 'L', 'O'};
System. Out.println (" why this print is address values?" + chars);

}
Results: after the output
Hello
Why is this print is address values? [21 bcffb5 C @

Why can the first normal, according to the second with a passage printed value is the address?
Solution,

CodePudding user response:

You look at the PrintStream class of API description
Println (char [] x)
Println (String) x
In simple terms, the former press string printed in the form of an array, the array into a string object (the default toString method calls, the default toString method returns the object types @ hash value) to print

CodePudding user response:

reference 1st floor qybao response:
you check the PrintStream class of API description
Println (char [] x)
Println (String) x
In simple terms, the former press string printed in the form of an array, the array into a string object (the default toString method calls, the default toString method returns the object types @ hash value) to print

Cook, understand understand, crab crab you,
  • Related