package cn.zhang;
public class Subject001 {
/*
* 输出小写的a-z以及大写的Z—A
* ASCII码: A~Z: a-z:
*/
public static void main(String[] args) {
System.out.println("------------1.使用ASCII码值输出------------");
for (int i = 97; i <= 122; i++) {
char ch = (char) i;
System.out.print(ch + " ");
}
System.out.println();
for (int i = 90; i >= 65; i--) {
char ch = (char) i;
System.out.print(ch + " ");
}
System.out.println();
System.out.println("------------2.使用字符输出------------");
for (char ch = 'a'; ch <= 'z'; ch++) {
System.out.print(ch + " ");
}
System.out.println();
for (char ch = 'Z'; ch >= 'A'; ch--) {
System.out.print(ch + " ");
}
}
}
结果: