Menu
Topics Index
...
`

Remove preoccured characters from the sentence


If you need explanation Read this topic

If you need Answer Take test on this topic

Write a program to remove the preoccured characters from the given sentence.

Input (String) Output (String)
Hello How are you Helo w ar yu
I am good boy I am god by
Indians love cricket Indas love crkt
Learn Java with Merit Campus Learn Jv with M Cpus



class RemovePreoccuredCharacters
{
    public static void main(String s[])
    {
        String sentence = "Hello How are you";
        System.out.println("After removing pre occured characters : " + removePreoccuredCharacters(sentence));

    }


    public static String removePreoccuredCharacters(String sentence) {
    }

}
Topic: toLowerCase() And toUpperCase() Methods In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

* here we need to remove the duplicate char in the give String
* take temp variable
* take for loop to travel through out the string
* check if the temp contains the present char(check for both cases)..if it is contains dont add otherwise add to the temp variable..if it is space than directly add to the temp

*contains() checks whether the given string is present pr not..

*for(i=0;i<input.length();i++)
if(!temp.contains(""+input.charAt(i))

*than add to the temp variable..

Posted by Uday Kumar    2015-01-26 06:14:34


This dose is now closed and the winners are Uday Kumar,  for 'First Correct Comment'. The 'lucky liker' is Gopinath Manchikanti. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-01-28 04:21:42


© meritcampus 2019

All Rights Reserved.

Open In App