settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: Print Characters - Letters in Java - Java Task

+7 votes

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

asked in Java category by user eiorgert
edited by user golearnweb

1 Answer

+1 vote
 
Best answer

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();
    }
}
answered by user hues
selected by user golearnweb
...