黑马程序员技术交流社区

标题: 麻烦大家帮我看下这道题,要分析 [打印本页]

作者: wuzeshui    时间: 2016-1-13 00:42
标题: 麻烦大家帮我看下这道题,要分析
下面的哪一个程序片断可能导致错误。 (    )
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";
  Stringstandard = s.toUpperCase();
D.
  String s ="home directory";
  s = s +"directory";


作者: OliverLC    时间: 2016-1-13 01:47
B 错
String不是数组,所以找不到s[3]

作者: aoejhx    时间: 2016-1-13 10:37
B。字符串要用String里的方法。而不是数组查找的方式




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2