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

14/05/2018 Categories: Strings. 1 Comment on Java program to print unique words in a given line of text

This java program reads a line of text from the user and prints out the unique words in ascending order.   We use TreeMap class from collections framework to store the frequency of each word in the given line of text and print out only the words with frequency 1, which will give us the […]

This java program reads a line of text from the user and prints out the unique words in ascending order.

 

We use TreeMap class from collections framework to store the frequency of each word in the given line of text and print out only the words with frequency 1, which will give us the unique words.

 

Program is as follows:

 

 

This program can also be tweaked to print the frequency of each word in a given line of text and also this can be extended to read a file line-by-line and find the unique words, frequency of each word, or the word that repeats the most and so on.

Related Links:

1 Comment

You can follow any responses to this entry through the RSS 2.0 feed.

Good morning sir -Suryateja Pericherla . I read your blog very suitable sllybus and with eg video .

Leave a Reply

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

Scroll Up