Java Code

Thanks Arun Tomar for providing the code.

Below is the solution with Java Collection perspective. Please see to it if it fine according to the best case solutions.

    public class Ritamtest
    {
        private static String name = "social.ritambhara.in";
        public static void main(String[] arun) {
            removeDuplicate(name);
        }
        private static void removeDuplicate(String str) {
            Set<Character> set = new TreeSet<Character>();
            for (int i = 0; i < str.length(); i++) {
                if (!(set.contains(str.charAt(i)))) {
                    set.add(str.charAt(i));
                }
            }
            for (char cha : set) {
                System.out.println("Set values : " + cha);
            }
        }
    }

Please let me know your feedback / suggestions / comments.

Pages: 1 2 3 4

2 Responses

Leave a Reply

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