Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

I am following the example of a book in Java. Using the example:

StringBuilder str = new StringBuilder();

str.append (" We sold ");

I am using Eclipse and the JDK 10 oracle and for some reason, the append method is not popping up, it is not there using Eclipse. I have the same problem by adding: import java.lang.*; but that did not work. Also, StringBuilder is an important class that I cannot afford to skip. 

I have also tried to fix the problem by adding: import java.lang.*; but that did not solve the issue. The compiler gives me the option of creating an append method or adding cast to append which does not work.

public static void main(String[] args) {

    StringBuilder str = new StringBuilder();

    str.append(" Joe");     

}

This is my full code:

import java.lang.*;

 public class StringBuilder

 {

 public static void main(String[] args)

 {

 StringBuilder str = new StringBuilder();

 str.append(" Joe");

 }

1 Answer

0 votes
by (13.1k points)

Do not name your class StringBuilder. It is a predefined method so try to rename it.

Want to learn Java? Check out the Core Java certification from Intellipaat.

Browse Categories

...