I would really appreciate any suggetions on changing my new code "Count characters in your text". | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

I would really appreciate any suggetions on changing my new code "Count characters in your text".

Initially, the code was created for the purposes of practicing the continue statement. The code calls the same method for different characters of the alphabet 26 times and I would like to make it more elegant. I thought about creating an enhanced for loop for an array with latin alphabet, yet, I got stuck with errors and ceased my attempts. May be someone has any ideas how this can be done? :) https://code.sololearn.com/cz421Bm7EycK/?ref=app

17th Oct 2018, 6:34 PM
ZdzichPych
ZdzichPych - avatar
6 Answers
+ 4
Your code had invisible non-spaces causing compile errors. I fixed those and added a for loop. https://code.sololearn.com/cV1aGX7Ifrzv
18th Oct 2018, 12:53 AM
John Wells
John Wells - avatar
+ 3
Zastanowił bym się nad połączeniem Class HashMap z ASCII, taka moja propozycja Można też stworzyć dwie tablice o takiej samej wielkości w jednej można przechowywać litery a w drugiej liczby
17th Oct 2018, 8:38 PM
Daniel (kabura)
Daniel (kabura) - avatar
+ 3
Daniel, dzieki wielkie za odpowiedz, na razie nie mialam okazji pocwiczyc tworzenie HashMaps, wiec chetnie sprobuje wykorzystac to rozwiazanie z tym kodem
18th Oct 2018, 5:03 AM
ZdzichPych
ZdzichPych - avatar
+ 3
John Wells, thank you very much for your solution, it is just the thing I thought about.
18th Oct 2018, 5:06 AM
ZdzichPych
ZdzichPych - avatar
+ 3
No wlasnie, jak cwicze jakas konstrukcje, staram sie przy okazji wykorzystac inne rzeczy :)
18th Oct 2018, 8:32 AM
ZdzichPych
ZdzichPych - avatar
+ 1
Zawsze można sobie jakoś fajnie zadanie utrudnić :) A to moje dzieło w drodze do pracy https://code.sololearn.com/cHtFlV1H1tFX/?ref=app
18th Oct 2018, 7:44 AM
Daniel (kabura)
Daniel (kabura) - avatar