An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
January 16, 2022 05:09 am GMT
Original Link: https://dev.to/riyas07/java-core-method-to-remove-duplicate-string-6o8
java traditional method to remove duplicate String
I just saw a post in dev someone solved same problem using collections in java. so i thought let me try the same problem to solve in traditional way`
public class Main
{
public static void main(String[] args) {
String s="abbvcddgtttt";
char c[]=s.toCharArray();
char cc[]=new char[c.length];
int index=0;
char same=' ';
for(int i=0;i<c.length;i++)
{
for(int j=i+1;j<c.length;j++)
{
if(c[i]==c[j])
{
c[i]=' ';
}
}
if(c[i]!=' ')
{
cc[index]=c[i];
index++;
}}for(char i:cc){
System.out.println(i);
}
}
}
Original Link: https://dev.to/riyas07/java-core-method-to-remove-duplicate-string-6o8
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To