When Java uses StringBuilder-the symbol is not found

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.