现在的位置: 首页 > 综合 > 正文

toString new String的区别

2017年01月08日 ⁄ 综合 ⁄ 共 229字 ⁄ 字号 评论关闭



                char[] temp = new char[] { 'a', 'b' };
String a = new String(temp);
String b = temp.toString();
System.out.println(a);// ab
System.out.println(b);// C@de6ced



toString   方法返回一个字符串,该字符串由类名(对象是该类的一个实例)、at   标记符“@”和此对象哈希码的无符号十六进制表示组成

new string 才生成了新字符串。



抱歉!评论已关闭.