Java code to remove duplicates in string

import java.io.*;
import java.util.*;

public class Solution {

    public static void main(String[] args) {
       String string = "Johnwilliams";
Set<Character> c = new LinkedHashSet<Character>();
for(int i=0;i<string.length();i++)
    {
    c.add(string.charAt(i));
}
        for(char c1:c)
    {
    System.out.print(c1);
}
   
       
    }
}

Comments

Popular posts from this blog

How whatsapp works

Android N Developer Preview? It's exciting for most of you