相同的代码在 IDE 中工作,但在 Cmd Line 中没有。这是我的代码。我找不到错误是什么?
import java.util.*;
import java.lang.*;
public class AppendingBuffer{
public static void main(String[] args){
StringBuilder sb;
sb = new StringBuilder("abc");
sb.append("def").reverse().insert(3, "---");
System.out.println(sb);
}
}
此处的两个屏幕截图显示了 IDE 和 Cmd 行程序。
命令行错误:
E:\java\6>javac AppendingBuffer.java
AppendingBuffer.java:7: error: constructor StringBuilder in class StringBuilder
cannot be applied to given types;
sb = new StringBuilder("abc");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
AppendingBuffer.java:8: error: cannot find symbol
sb.append("def").reverse().insert(3, "---");
^
symbol: method append(String)
location: variable sb of type StringBuilder
.\StringBuilder.java:5: error: constructor StringBuilder in class StringBuilder
cannot be applied to given types;
StringBuilder sb = new StringBuilder("abc");
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
.\StringBuilder.java:6: error: cannot find symbol
sb.append("def").reverse().insert(3, "---");
^
symbol: method append(String)
location: variable sb of type StringBuilder
4 errors
E:\java\6>