In this task, we’d need to find the occurrences of every character in the String value.

Additionally, we’d have to follow some rules. Here is the list:

  • The algorithm should be case-insensitive. In other words, we’d treat the upper-case and lower-case representations of the letter as it’s the same.
  • Next, the algorithm should write the total number of characters in the console.
  • Lastly, we should write the total occurrence number for each letter in the console as well.


String myString = "I love summer nights"


String has 20 characters, 3 whitespaces.
Character occurrence:
e - 2
g - 1
h - 1
i - 2
l - 1
m - 2
n - 1
o - 1
r - 1
s - 2
t - 1
u - 1
v - 1


You can use Map with keys representing each character.

Too Easy?

This was too easy for you? Try to create a mechanism for message encryption.


You can check if everything is working as expected before submitting your solution. Click on the icon to download tests.

Send Us Your Solution

If you’re interested in our feedback, please send us your solution here. We’ll review it and let you know.

    By Ana Peterlić

    Ana is a Java Software Engineer with over 6 years of experience in designing and developing software solutions. She loves tutoring and helping others understand Java ecosystem.