做工精细字符串,如果建立这样的:创建一个从字节[]
String ss = new String({1,2});
甚至这样:
String ss = new String({(byte)1,(byte)2});
什么是
byte [] d = {1,2};
String ss = new String(d);
但是,如果建立这样的失败问题?
做工精细字符串,如果建立这样的:创建一个从字节[]
String ss = new String({1,2});
甚至这样:
String ss = new String({(byte)1,(byte)2});
什么是
byte [] d = {1,2};
String ss = new String(d);
但是,如果建立这样的失败问题?
String ss = new String (array of bytes);
we can pass here array of bytes but in
String ss = new String({1,2}); {1 , 2} this is not an array and
String ss = new String({(byte)1,(byte)2}); {(byte)1,(byte)2} this is also not an array
So we can simply use
String ss = new String(new byte[]{1,2});
编译器说什么? – Ingo