日期:2014-05-20  浏览次数:20813 次

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)不可用