打印26个字母,在'a'上加偏移量

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hju22/article/details/83451526

打印26个字母

方法:在’a’上加偏移量

package com.word.word;
//打印26个字母
public class PrintLowerCase {
    public static void main(String[] args) {
        for(int i=0;i<26;i++){
            int c='a'+i;   //'a'会自动转换为int以执行加法
            System.out.print((char)c);  //为了打印字符,必须将c强制转为char
        }
    }
}

结果:
坚持比努力更重要

猜你喜欢

转载自blog.csdn.net/hju22/article/details/83451526