CJCoding With Joseph
15per day
← Back to Question List

Select topics to narrow your question pool, then enable Random to jump to a random question matching your filters.

Topics:
Java Quiz #14

Count Letter A

mediumLoops

What does this code output?

📄 Code

1String str = "Java is amazing";
2int count = 0;
3for (int i = 0; i < str.length(); i++) {
4 if (str.charAt(i) == 'a') {
5 count++;
6 }
7}
8System.out.println(count);