我对编程很陌生,可以使用一些帮助。我正在学习如何使用 StringBuffer 类,并且我编写了一个简单的代码。但是,当我尝试运行程序时,我不断收到错误消息“找不到符号”。任何建议都会很棒!谢谢!
public class StringBuffer{
public static void main(String[] args)
{
StringBuffer sbuff = new StringBuffer();
//one attempt to append - error
sbuff.append("Jenna");
//second attempt to append - error
String phrase = new String("Jenna");
sbuff.append(phrase);
//attempts to call upon other methods - errors
System.out.println("Your name backwards is: " + sbuff.reverse());
System.out.println("The length of your name is: " +sbuff.length());
}
}
确切的错误如下所示:
cannot find symbol
symbol: method append(java.lang.String)
location: variable sbuff of type StringBuffer
reverse
和的类似错误length
。