Never forget break.

Source: Internet
Author: User

Never forget break.

Public class client (

Public static void main (String [] argw ){

System. out. println ("2 =" + numCase (2 ));

}

 

Public static String numCase (int n ){

String ChinessNumber = "";

Swith (n ){

Case 0: ChinessNumber = "0 ";

Case 0: ChinessNumber = "1 ";

Case 0: ChinessNumber = "II ";

Case 0: ChinessNumber = "";

Case 0: ChinessNumber = "Si ";

Case 0: ChinessNumber = "Wu ";

Case 0: ChinessNumber = "";

Case 0: ChinessNumber = "success ";

Case 0: ChinessNumber = "success ";

Case 0: ChinessNumber = "success ";

}

Return ChinessNumber;

}

)

 

 

The result is 2 = success.

 

Break must be added after the case statement;

You can solve this problem by modifying the warning level of the IDE. For example, in Eclipse, you can use the metrics maces-java-compiler-Errors/Warnings-Potential Programming problems, then modify the 'sWith 'case fall-through Errors level. If you dare not add break to the case statement, Eclipse will report a Red Cross for you.

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.