Generate a string containing all Chinese characters "one" word start "\4e00 to 9fa5

Source: Internet
Author: User

/** * Generates a string containing all Chinese characters "one" word begins "\4e00 to 9FA5 * idea: * 1. Since it is all that contains, it is definitely from one character to another character of all characters * 2. Because each string object creates a different one, it will open up empty , avoid wasting memory, with StringBuilder stitching better * 3. Because it is the output of all stitching problems, so with the loop * 4. In order to avoid too many rows to display, 50 a newline display, so a counter * * Step * 1 is required. Loop variable initialization, where the loop variable should is the character C (\u4e00), * in the constant addition of 1 C + +, loop to the last 1 characters end C<=\U9FA5 * 2. Because there is a counter I, so stitching a character, should add a count of i++ * 3. Loop the body, establish the StringBuilder object. * Each loop stitching Sb.append (c) * 4. Wait I to 50, just sb.append ("\ n") * Note: Counter starts from 1, otherwise the first word, i%50 0 modulo 50, the result is 0, will wrap * Output statement on the outermost, direct output SB object. */
 public  class   StringDemo3 { static  void   main (string[] args) {int  i=1;        StringBuilder sb  = new   StringBuilder ();  for  (char  c= ' \u4e00 '; c<= ' \            U9fa5 '; C++,i++) {Sb.append (c);  if  (i%50 ==0) {Sb.append ( "            \ n ");    }} System.out.print (Sb.tostring ()); }}
View Code

Generate a string containing all Chinese characters "one" word start "\4e00 to 9fa5

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.