Wrote a test and tried the Java StringBuilder class.
The code is as follows:
Import Java.util.Scanner;
public class StringBuilder1
{
public static void Main (string[] args)
{
Scanner in = new Scanner (system.in);
System.out.println ("Start building a string with many small pieces of string:");
System.out.println ("First build an empty string constructor");
StringBuilder builder = new StringBuilder ();
System.out.println ("constructor build succeeded");
System.out.println ("We start adding strings to the constructor");
Char choose = ' C ';
Do
{
SYSTEM.OUT.PRINTLN ("What does want to add:");
System.out.println ("A.char");
System.out.println ("B.str");
System.out.println ("C.finish");
Choose = In.nextline (). charAt (0);
Switch (choose)
{
Case ' a ': Builder.append (In.nextline (). CharAt (0)); Break
Case ' B ': Builder.append (In.nextline ()); Break
Case ' C ': System.out.println (Builder.tostring ());
}
}while (Choose! = ' C ');
}
}
The above is the correct code that the console can
As for the symbol not found
is because the class name of the base class takes StringBuilder when testing
The result is the same as the class name in Java.lang.StringBuilder
After change StringBuilder1 bug resolved.
This article is from the "Kivilin_it_start" blog, make sure to keep this source http://kivilin.blog.51cto.com/6914610/1628017
When Java uses StringBuilder-the symbol is not found