My Blog
Articles related to programming, computer science, technology and research.

14/05/2018 Categories: Strings. No Comments on Java program to print only unique characters in a string

This java program reads a string from the user, and prints out only the unique characters in the string in insertion order.


First we find out the frequency of each character in the string and then print out only the characters that have frequency as 1. To maintain the insertion order, we use LinkedHashMap class from collections framework.


The program is as follows:



For printing in ascending order, use TreeMap class instead of LinkedHashMap class.

Related Links:

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up