Joachim Sauer :

'A' is 65. 'a' is 97. Use 97 instead of 65 in your final loop.\nAlternatively use 'a' directly instead of the number. This makes it more obvious what you're doing in that code.",
2021-10-19T08:28:53
Nowhere Man :

It may be more straightforward to convert the entire string to lower case to avoid checking for upper case letters.\nAlso, as suggested earlier using character literals as a instead of 97 would make the code more readable.\nScanner sc = new Scanner(System.in);\nint a[] = new int[26];\n\nString str = sc.nextLine().toLowerCase();\n\nfor (char c : str.toCharArray()) {\n if (c >= 'a' && c <= 'z') {\n a[c - 'a']++;\n }\n}\nfor (char c = 'a'; c <= 'z'; c++) {\n int i = c - 'a';\n if (a[i] > 0) {\n System.out.print(" "+ c + "(" + a[i] + ")");\n }\n}\n",
2021-10-20T12:36:08
yy