In Java class name must be TreeSetUse Write a program that reads a line of text input by the user and places each word in a TreeSet. Print the elements of the TreeSet to the screen. This will cause the elements to be printed in ascending order
In Java
class name must be TreeSetUse
Write a program that reads a line of text input by the user and places each word in a TreeSet. Print the elements of the TreeSet to the screen. This will cause the elements to be printed in ascending order.

Algorithm
Step1: In class Treeset, declare the Treeset of type string.
Step2: Ask the line as input from user and using loop get the each word by split() and add to treeset one by one.
Step3: Declare the iterator of treeset and using while loop, as true by hasnext() function. and retrieve words.
Step4: Print the words one by one using next() function in assending order.
Step by step
Solved in 4 steps with 2 images

Doesn't look like anything is written in Java. The program needs to take input and put each word in a TreeSet. Can you help with that?








