Java Program to Remove Duplicates From String

program in java to remove duplicates from string

In this tutorial, We will learn writing the java program to remove the duplicate characters from the String. Take any string as an input from the user and check for duplicate characters and if there is any duplicity of characters then remove it.

For example

Case1: If the user inputs the string ‘programmingLanguage’

Then the output should be ‘ogumapenirL’, where there is no character that is repeating.

Case2: If the user inputs the string ‘LearningIsFun’

Then the output should be ‘LergisIauFn’, where there is no character that is repeating.

Java Program to Remove Duplicates From String

Output

Explanation

Here, the user gives input as ‘Quescol Website’, so first, the character of the string gets converted into elements of the set, so the duplicates will get removed.

After that, the elements of the array returned as the output ‘Quescol Wbit’.