4. 下面的哪些java程序片断可能导致错误?(二)
来源:百度知道 编辑:UC知道 时间:2024/06/06 20:06:27
A. String s = "Gone with the wind";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = s.toUpperCase();
D. String s = "home directory";
String t = s - "directory";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = s.toUpperCase();
D. String s = "home directory";
String t = s - "directory";
B会出错. String不可以那样子访问的.除非转换成数组
D也会出错..String不支持'-'运算符.
快快给分!!!!!!!!!!!!!!!!
B
s是String 对象,不能用数组啊.应该是s.charAt(3)