当前位置: 代码迷 >> Eclipse >> 新手java程序有错请求们帮解决
  详细解决方案

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

热度:87   发布时间:2016-04-23 13:59:22.0
新手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就没事了....
  相关解决方案