3
28/10/2024 7:05 pm
Emne 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:

1 Svar
2
28/10/2024 7:05 pm
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();
}
}
Vær venlig at Log ind eller Registrere for at svare på dette emne.
