Sunday , December 11 2016
Home / Blue J / java program for eliminating the multiple characters occurring in a string using string buffer functions

java program for eliminating the multiple characters occurring in a string using string buffer functions

This java program is for eliminating repeated characters in a string step by step.


class frequency
{
public static void main(String s)
{
int i,z=0,max,k,j,c=0,L,a=0;
L=s.length();
String s1=s.toLowerCase(); // eliminating charachters can be both in uppercase and lower case this program treats both the case similarly.
if(s1.charAt(0)==s.charAt(0))
z=1;
for(k=0;k

{max=1;
for(i=97;i<123;i++)
{
c=0;
for(j=0;j
{
int x1=(int)s1.charAt(j);
if(x1==i)
c++;
if(c>=max)
{
max=c;
a=i;
}
}
}
String t=””;
if(max!=1)
{
for(i=0;i
{
int y=(int)s1.charAt(i);
if(y!=a)
{
if(z==0)
{
s=s1.toUpperCase();
System.out.print(s.charAt(i));
}
else
System.out.print(s1.charAt(i));
t+=s1.charAt(i);
}
}
}
s1=t;
System.out.println();
L=s1.length();
}
}
}


OUTPUT:

Tags: bluej program for frequency, program for displaying a string with single characters, program for eliminating repeated characters in a string.

Also See:   Java program for Floyds Triangle

Check Also

Program for Matrix Multiplication in JAVA

Matrix Multiplication:– Here is given a Java Program for Matrix Multiplication also call matrix product. In ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.