当前位置: 代码迷 >> Java相关 >> String.charAt(),找不到源,该怎么解决
  详细解决方案

String.charAt(),找不到源,该怎么解决

热度:1977   发布时间:2013-02-25 21:51:51.0
String.charAt(),找不到源
新手哦,不懂怎么弄
程序如下:package smilelee;
/**
 * 将str1的部分字符复制到str2
 * @author Administrator
 *
 */
public class WhileDemo 
{
public static void main(String[] args)
{
String str1="You are a good boy,but you're not the best one!";
StringBuffer str2=new StringBuffer();
int i=0;
char c=str1.charAt(i);
while(c!='d')
{
str2.append(c);
str1.charAt(++i);
}
System.out.println("This is the str2:"+str2);
}
}


Eclipse编译的

------解决方案--------------------------------------------------------
在我的环境下是好的没有任何问题,String.charAt方法在JDK1.4以后就有了,你重新编译下这个文件
还有你的JDK版本应该肯定支持吧,看看eclipse里面编译器complier版本在1.4以上么?

探讨

刚刚试了一下可是还是一样的没有解决问题啊,提示String.charAt(i)不可用
  相关解决方案