Java program to print alphabets
Java program to print alphabets on screen, i.e., a, b, c, ..., z; in lower case.
Java source code
- class Alphabets
- {
- public static void main(String args[])
- {
- char ch;
- for (ch = 'a'; ch <= 'z'; ch++)
- System.out.println(ch);
- }
- }
You can easily modify the above java program to print alphabets in upper case.
Output of program:
Printing alphabets using a while loop (Only the body of the main method is shown):
- char c = 'a';
- while (c <= 'z') {
- System.out.println(c);
- c++;
- }
Using a do while loop:
- char c = 'A';
- do {
- System.out.println(c);
- c++;
- } while (c <= 'Z');
Comments
Post a Comment