下面这段代码会产生(B )个String对象.String s1 = "hello";String s2 = s1.substring(2,3); String s3 = s1.toString(); String s4 = new StringBuffer(s1).toString(); A、1 B、2 C、3 D、4

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/01 13:18:58
下面这段代码会产生(B )个String对象.String s1 =

下面这段代码会产生(B )个String对象.String s1 = "hello";String s2 = s1.substring(2,3); String s3 = s1.toString(); String s4 = new StringBuffer(s1).toString(); A、1 B、2 C、3 D、4
下面这段代码会产生(B )个String对象.
String s1 = "hello";
String s2 = s1.substring(2,3);
String s3 = s1.toString();
String s4 = new StringBuffer(s1).toString();
A、1 B、2 C、3 D、4

下面这段代码会产生(B )个String对象.String s1 = "hello";String s2 = s1.substring(2,3); String s3 = s1.toString(); String s4 = new StringBuffer(s1).toString(); A、1 B、2 C、3 D、4
楼上太强了,不得不俯首称赞;
都是变量声明语句嘛;
String s1 = "hello";
String s2 = s1.substring(2,3); 截取第一个字符串
String s3 = s1.toString();
String s4 = new StringBuffer(s1).toString();新建一个Buffer又转为String