Java Beginer
Java Beginer

Reputation: 321

Same set of Code Working in Eclipse IDE and not working in Command Line

The same code working in IDE, but not in Cmd Line. Here is my code. I cannot find what the error is?

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);
    }
}

The two screen shots are here which shows the both IDE and Cmd line programs.

Error In Command Line:

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>

Java Command Line Java IDE

Upvotes: 2

Views: 1119

Answers (1)

Reimeus
Reimeus

Reputation: 159754

Chances are you have another class StringBuilder on the classpath. Either rename the local source file or remove it completely before attempting to re-compile it.

Upvotes: 7

Related Questions