[Solved] Print Characters - Letters in Java - Java Task

  

3
Topic starter

Print the characters from ‘a’ to ‘z’ on the console on a single line, separated by a space. Use a for-loop. Note: you can directly declare and increment char in the for-loop. for (char c = ‘a’; …)

It must look like this:

print charactrers in java

1 Answer
2

Easy task indeed - like in C# - you must know for loop and know that instead of numbers you can use char data type - from 'a' to 'Z';

Here is my solution:

public class PrintCharacters04 {
    public static void main(String[] args) {
        for (char i = 'a'; i < 'z'; i++) {
            System.out.print(i + " ");
        }
        System.out.println();
    }
}
Share: