1.String s=new String("abc");
String ss=new String(s);
2.Byte b=new Byte((byte)1);
Byte bb=new Byte(b);
3.Integer i=new Integer(1);
Integer ii=new Integer(i);
为什么只有String那一组中的ss能够初始化成功???像第二组里面Byte bb=new Byte(b);Byte的构造函数要接受String或者byte对象,这里传一个reference进去就有问题了吗?
String ss=new String(s);
2.Byte b=new Byte((byte)1);
Byte bb=new Byte(b);
3.Integer i=new Integer(1);
Integer ii=new Integer(i);
为什么只有String那一组中的ss能够初始化成功???像第二组里面Byte bb=new Byte(b);Byte的构造函数要接受String或者byte对象,这里传一个reference进去就有问题了吗?
public Byte(String s)
throws NumberFormatException构造一个新分配的 Byte 对象,以表示 String 参数所指示的 byte 值。该字符串以使用基数 10 的 parseByte 方法所使用的方式被转换成一个 byte 值。
就可以了