java-Print Alphabet

Source: Internet
Author: User

The last final exam, the second-lowest question of the nth small question ... Print 26 uppercase and lowercase alphabets

is a very simple small topic, but still pull out research research (People's bullish thinking in Java have written this example, I rewrite not embarrassing!!! )

Previous topic:

?
123456789101112131415161718 public class Demo {    public static void main(String[] args) {        /*char和int类型能够相互转换,相信大家都明白          什么?不明白???那只能怪你大一c语言老师死的早 */        //为什么是0~128的取值范围?其实这只是个大概范围,具体看看编码表就一目了然了        for (char c = 0; c < 128; c++) {             //java里边包装类的一个静态方法,确定c是字母还是小写!!!)            if (Character.isLowerCase(c)) {                 //我没用println,why?你可以试试println()看对齐效果                System.out.printf("value: %3d  char: %c\n", (int)c, c);             //同上,判断c是大写            } else if (Character.isUpperCase(c)) {                 System.out.printf("value: %3d  char: %c\n", (int)c, c);            }        }    }}

--# Well, the resolution is not high, you can only cut so much, anyway, the size is written out, the contents of the bottom left to the novice to imagine ...

Something:

I think that a person can make simple things look complicated, and then return to the simple, then this person must be very impressive.

Simply put, a few lines of code to use the technique is nothing more than the conversion of char and int type

But have you ever thought about the question of the value range of char?

What about the design of the coded table and the other characters represented by the decimal?

And what is the wrapper class, a way for God's horse to be able to quickly differentiate the case?

What if you want to determine whether any number can be converted to a char type of letter?

And then, what's the difference between System.out.println () and System.out.printf ()?

For more information, please analyze yourself ...

java-Print Alphabet

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.