“Auto increment” alphabet in Java?

后端 未结 10 2168
情书的邮戳
情书的邮戳 2020-12-02 16:53

\"Auto increment\" alphabet in Java - is this possible? From A to Z without a third-party library?

10条回答
  •  天命终不由人
    2020-12-02 17:26

    Here's the code without a third-party library,

    public class JavaPrintAlphabet
    {
       public static void main(String[] args)
       {
          System.out.println("Printing the alphabets from A to Z : ");
          char alpha;
    
          for(alpha = 'A'; alpha <= 'Z'; alpha++)
          {
             System.out.println(alpha);
          }
       }
    }
    

    Output

    Printing the alphabets from A to Z : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    

    For more on a Java program to print the alphabet, refer this resource.

提交回复
热议问题