Count letters in a string Java

前端 未结 5 1341
一向
一向 2020-12-10 09:33

I\'m doing an assignment where I\'ll have to code a program to read in a string from user and print out the letters in the string with number of occurrences. E.g. \"Hell

5条回答
  •  再見小時候
    2020-12-10 09:56

    No you should not create an array of 26. This will break if the string contains unexpected characters. (ä, ö, ü anyone?) As I pointed out im my comment use a Map. This will work forr all posible characters out there.

提交回复
热议问题