Class 10 Class 11 Class 12

Removing Repeated Letters From A String

Write a program to input a string from the user in lowercase form.

Then remove all the repeated letters from the string and keep only single occurrences of the characters present in the string.

Display the final string formed after the removal of the extra repeated characters.

INPUT: applications
OUTPUT: aplictons

class Repeated{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(;
        System.out.print("String: ");
        String s = br.readLine().toLowerCase();
        String t = "";
        while(s.length() > 0){
            t += s.charAt(0);
            s = s.replace(Character.toString(s.charAt(0)), "");

By admin

I am a Computer Science teacher in one of the renowned schools in India. I teach Java programming language to my students, and I maintain a website

4 replies on “Removing Repeated Letters From A String”

Sir,a program is given which states that:
WAP in Java to accept a binary number and convert it to its decimal equivalent using recursive function. Display a suitable message if the binary number is negative and if it does not contain 1 and 0.
Sample Input:
Enter a binary number:110011
Sample Output:
The Decimal Equivalent:51

We first take one character from the string, place it to the new string, and then replace that character with an empty string.
This is repeated as long as the original string has characters left in it.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.