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