public class Abc{
public static void main(String[] args){
String letters = "ABC";
char[] numbers = {"1", "2", "3"};
System.out.println(letters + " easy as " + numbers );
}
}
Solution:
显示(像是):ABC easy as [C@16f0472
由于char[] numbers 是一个类对象,而在+中又重载了Object取得对象地址的方法。
TID:
The char[] overloading of println prints all of the characters contained in the array, and the char[] overloading of String.valueOf and StringBuffer.append behave analogously.
REturns a string consisting of the name of the class of which the object is an instance, the at-sign character '@', and the unsigned hexadecimal representation of the hash code of the object.
Correctly:
System.out.println(letters + " easy as " + String.valueOf(numbers));
or:
System.out.print(letters + " easy as ");
System.out.println(numbers);