黑马程序员技术交流社区

标题: 有没有人能够解释一下这个代码错误? [打印本页]

作者: 探索者    时间: 2015-6-1 12:37
标题: 有没有人能够解释一下这个代码错误?
错误代码:

  1. class StringSort3 {

  2. /**
  3. * @param args
  4. */
  5.         static String string="abc";
  6.         public static void main(String[] args) {
  7.                         // TODO Auto-generated method stub
  8.                         show(1,new String());
  9.         }
  10.         public static void show(int len, String temp) {
  11.                         // TODO Auto-generated method stub
  12.                         if(len<string.length()){
  13.                                         for(int i=0;i<string.length();i++){
  14.                                                         if(!temp.contains(string.substring(i,i+1))){
  15.                                                         System.out.print(temp+string.substring(i,i+1)+" ");
  16.                                                         show(len+1, new String(temp+string.substring(i, i+1)));
  17.                                                         }
  18.                                         }
  19.                         }
  20.                        
  21.         }

  22. }
复制代码

错误提示:The method contains(CharSequence) from the type String refers to the missing type
         CharSequence
        - The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from
         required .class files

有人知道原因吗?

作者: wuyusi    时间: 2015-6-1 12:59
你使用操作字符串数组的方法在操作字符串,将“abc”改成字符串数组再试一次
作者: 探索者    时间: 2015-6-1 13:05
wuyusi 发表于 2015-6-1 12:59
你使用操作字符串数组的方法在操作字符串,将“abc”改成字符串数组再试一次 ...

这个问题只有在eclipse里出现,而在editplus里用dos运行正常
作者: wuyusi    时间: 2015-6-1 13:18
我找个时间试下,还要多多努力




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