各位高手可以帮帮我吗???
代码如下:import java.lang.StringBuffer.*;
public class ContinueExample
{
public static void main(String args[])
{
StringBuffer searchMe = new StringBuffer("Peter Piper picked a peck of picked peppers");
int max = searchMe.length();
int numps = 0;
for (int i = 0;i < max ;i++)
{
if(searchMe.charAt(i) != 'p')
{
continue;
}
numps++;
searchMe.setcharAt(i,'P');
}
System.out.println("Found"+numps+"p's in the old string .");
System.out.println("The new string is :");
System.out.println(searchMe);
}
}
可是编译时出现如下错误:
ContinueExample.java:24: 找不到符号
符号: 方法 setcharAt(int,char)
位置: 类 java.lang.StringBuffer
searchMe.setcharAt(i,'P');
各位大哥,谢啦!!!
^
----------------解决方案--------------------------------------------------------
方法名写错了,JAVA中区分大小写的,searchMe.setCharAt(i,'P');
----------------解决方案--------------------------------------------------------
希望对你有帮助
----------------解决方案--------------------------------------------------------
非常谢谢你!!
----------------解决方案--------------------------------------------------------