Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java String Maniplulation

Name: Anonymous 2011-05-22 22:37

this doesn't work if the first letter has a duplicate at the end. what am i doing wrong?

    /**
     * Removes duplicate characters. Only latter instances<br/>
     * are deleted
     * @param s - the original
     * @return the string with dupes removed
     */
    public static String removeDuplicates(String s){
        for (int x = 0; x < s.length(); x++){
            for (int k = x + 1 ; k < s.length(); k++){
                if (s.charAt(x) == s.charAt(k))
                    s = s.substring(0, k) + s.substring(k + 1);
            }
        }
        return s;
    }

Name: Anonymous 2011-05-23 2:07

>>13
what is wrong with this if statement? it checks if the letters i'm comparing are the same...

>>16
i'm going to teach myself C++ this summer.
how do i avoid the path of the code monkey?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List