Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 16, 2022 05:09 am GMT

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`

  1. 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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To