This weeks programming exercise is to
write a program to find repeated characters in a String. For example if given input to your program is "Java", it should print all duplicates characters, i.e. characters appear more than once in String and their count e.g.
a = 2, because character
'a' has appeared twice in String
"Java". This is also a very popular coding question on various level of Java interviews and written test, where you need to write code. On difficulty level this question is at par with
prime numbers or
Fibonacci series. I personally like this exercise because it gives beginners an opportunity to familiar with concept of Map data-structure, which allows you store mappings in form of key and value. Since Map is heavily used in any enterprise Java application, good knowledge of this data structure is highly desirable among any level of Java programmers. By the way there are couple of variant of this program, sometime interviewer will ask you to read a file and print all duplicate characters and their count, core logic will remain same, all you need to do is demonstrate how much you know about File IO in Java e.g. streaming file if its very large rather than reading whole file in memory.