在IDE中工作的代碼相同,但不在Cmd Line中工作。這是我的代碼。我找不到錯誤是什麼?在Eclipse IDE中工作並且不在命令行中工作的代碼的相同集合
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>
您可以再次單獨發佈錯誤消息嗎?這很難閱讀。 – 0xCAFEBABE
您正在運行'javac'的目錄中還有其他文件? – millimoose
以及它在我的系統上的工作 – exexzian