"Write a program to input a word from the user and remove the duplicate characters present in it." Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Write a program to input a word from the user and remove the duplicate characters present in it." answered properly. Developers are finding an appropriate answer about Write a program to input a word from the user and remove the duplicate characters present in it. related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Write a program to input a word from the user and remove the duplicate characters present in it.. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Write a program to input a word from the user and remove the duplicate characters present in it..
Write a program to input a word from the user and remove the duplicate characters present in it.
// Java program to remove duplicate/repeated characters from a string www.getprogramcode.com
import java.util.*;
class RemoveDuplicate
{
public static void main(String args[])
{
String s,ans="";
char ch ;
int l,i=0;
Scanner sc=new Scanner(System.in);
System.out.print("Enter any string: "); // Inputting the word
s = sc.nextLine();
l=s.length();
s+=" "; // *Adding extra space at the end because last character is compared with something else index out of bound error.
ch=s.charAt(0); // taking ch as first character
while(i<l)
{
ans= ans+ ch; // adding each individual character to the answer string or output string without repeated characters
while(s.charAt(++i)==ch && i<l)
{}
ch=s.charAt(i); // **to store the previously last character in ch
}
System.out.println("String after removing repeated characters : \n"+ans); // Printing the string without duplicate characters
}
}
Source: programcodelib.com
All those coders who are working on the Whatever based application and are stuck on Write a program to input a word from the user and remove the duplicate characters present in it. can get a collection of related answers to their query. Programmers need to enter their query on Write a program to input a word from the user and remove the duplicate characters present in it. related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Write a program to input a word from the user and remove the duplicate characters present in it. for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Write a program to input a word from the user and remove the duplicate characters present in it. while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Write a program to input a word from the user and remove the duplicate characters present in it.". Visit this developer's friendly online web community, CodeProZone, and get your queries like Write a program to input a word from the user and remove the duplicate characters present in it. resolved professionally and stay updated to the latest Whatever updates.