Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

String remove duplicate method in java

public static void main(String[] args) {

        String result = removeDup("AAABBBCCC");
        System.out.println(result); // ABC

public static  String  removeDup( String  str) {
        String result = "";
        for (int i = 0; i < str.length(); i++)
            if (!result.contains("" + str.charAt(i)))
                result += "" + str.charAt(i);
        return result;
    }
}
Source by devqa.io #
 
PREVIOUS NEXT
Tagged: #String #remove #duplicate #method #java
ADD COMMENT
Topic
Name
2+5 =