2013-06-25 19 views

回答

1

不,这是班级名称([Bbyte[]),散列码(1339a0dc是十六进制的散列码)。哈希不能被逆转,因为它们不是bijective

为什么打印这个?因为您使用的是隐式toString()。这:

System.out.println(str.getBytes()); 

被编译器翻译成这样:

System.out.println(str.getBytes().toString()); 

因为System.out.println()需要String作为参数,因此隐式转换在这里制造。

所以你使用的是默认Object#toString()实现,正如我以前(更多详情in the documentation

2

getBytes返回byte阵列解释其工作原理。所以你可以这样做:

byte[] bytes = str.getBytes(); 

直接。

[[email protected]只是一个表示为String的对象引用,它不是实际的字节数组