你的输出错了吧。 你打印的是类吧,不是中文。 class a system.out.println(a); 就是你这样 system.out.println(a.a);a.a才是内容
你要打印对象的内存地址,如果你要输出你想要的结果可以重写该类的toString()方法
public class ArrayString { public static void main(String[] args) { byte[] ba = new byte[0]; short[] sa = new short[0]; int[] ia = new int[0]; long[] la = new long[0]; float[] fa = new float[0]; double[] da = new double[0]; char[] ca = new char[0]; boolean[] bla = new boolean[0]; System.out.println(ba.toString()); System.out.println(sa.toString()); System.out.println(ia.toString()); System.out.println(la.toString()); System.out.println(fa.toString()); System.out.println(da.toString()); System.out.println(ca.toString()); System.out.println(bla.toString()); }}程序输出:[B@de6ced [S@c17164 [I@1fb8ee3 [J@61de33 [F@14318bb [D@ca0b6 [C@10b30a7 [Z@1a758cb其中@后面是十六进制表示的内存地址。
说的不准确 纠正 并非单纯的hashcode 源码如下 /** * Returns a string representation of the object. In general, the * <code>toString</code> method returns a string that * "textually represents" this object. The result should * be a concise but informative representation that is easy for a * person to read. * It is recommended that all subclasses override this method. * <p> * The <code>toString</code> method for class <code>Object</code> * returns a string consisting of the name of the class of which the * object is an instance, the at-sign character `<code>@</code>', and * the unsigned hexadecimal representation of the hash code of the * object. In other words, this method returns a string equal to the * value of: * <blockquote> * <pre> * getClass().getName() + '@' + Integer.toHexString(hashCode()) * </pre></blockquote> * * @return a string representation of the object. */ public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); }
楼主【wudaoshengu】截止到2008-07-02 10:55:42的历史汇总数据(不包括此帖):
发帖的总数量:24 发帖的总分数:810
结贴的总数量:22 结贴的总分数:720
无满意结贴数:2 无满意结贴分:60
未结的帖子数:2 未结的总分数:90
结贴的百分比:91.67 % 结分的百分比:88.89 %
无满意结贴率:9.09 % 无满意结分率:8.33 %
值得尊敬
class a
system.out.println(a); 就是你这样
system.out.println(a.a);a.a才是内容
byte[] ba = new byte[0];
short[] sa = new short[0];
int[] ia = new int[0];
long[] la = new long[0];
float[] fa = new float[0];
double[] da = new double[0];
char[] ca = new char[0];
boolean[] bla = new boolean[0];
System.out.println(ba.toString());
System.out.println(sa.toString());
System.out.println(ia.toString());
System.out.println(la.toString());
System.out.println(fa.toString());
System.out.println(da.toString());
System.out.println(ca.toString());
System.out.println(bla.toString());
}}程序输出:[B@de6ced
[S@c17164
[I@1fb8ee3
[J@61de33
[F@14318bb
[D@ca0b6
[C@10b30a7
[Z@1a758cb其中@后面是十六进制表示的内存地址。
并非单纯的hashcode
源码如下 /**
* Returns a string representation of the object. In general, the
* <code>toString</code> method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
* It is recommended that all subclasses override this method.
* <p>
* The <code>toString</code> method for class <code>Object</code>
* returns a string consisting of the name of the class of which the
* object is an instance, the at-sign character `<code>@</code>', and
* the unsigned hexadecimal representation of the hash code of the
* object. In other words, this method returns a string equal to the
* value of:
* <blockquote>
* <pre>
* getClass().getName() + '@' + Integer.toHexString(hashCode())
* </pre></blockquote>
*
* @return a string representation of the object.
*/
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
getClass().getName() + '@' + Integer.toHexString(hashCode())