首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

新手java程序有错请求们帮解决

2012-01-23 
新手java程序有错请求大虾们帮解决package zixue.Stringpublic class StringBuffer {public static void

新手java程序有错请求大虾们帮解决
package zixue.String;

public class StringBuffer {
public static void main(String[] args){
StringBuffer ab = new StringBuffer();

ab.append("This ");
ab.append("book ");
ab.append("is ");
ab.append("mine.");

System.out.println(ab);
ab.setCharAt(5,'B');
System.out.println(ab);
}
}

有错:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
The method append(String) is undefined for the type StringBuffer
The method append(String) is undefined for the type StringBuffer
The method append(String) is undefined for the type StringBuffer
The method append(String) is undefined for the type StringBuffer
The method setCharAt(int, char) is undefined for the type StringBuffer

at zixue.String.StringBuffer.main(StringBuffer.java:7)
看不懂啊哥哥们……
帮帮忙啦

[解决办法]
你的类名和保留字StringBuffer冲突了,你把类名换一个,比如换成StringBuffer1就没事了....

热点排行