Java - Write code to removes duplicate characters from the String

Requirements

Write code to removes duplicate characters from the String

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String inputString = "book2s.com";
        System.out.println(getUniqueCharString(inputString));
    }// w  ww .  ja  v a2 s  . c  o m

    /***
     * getUniqueCharString(final String inputString)
     * This method removes duplicate characters from the String
     * @param inputString
     * @return String 
     */
    public static String getUniqueCharString(final String inputString) {
        final char[] inputCharArray = inputString.toCharArray();
        final int countChar[] = new int[59];
        char[] outputArray = new char[inputCharArray.length];
        int index = 0;
        for (char c : inputCharArray) {
            if (countChar[((int) c - 64)] == 1) {
                outputArray[index] = c;
                index++;
            }
            countChar[((int) c - 64)] = countChar[((int) c - 64)] + 1;
        }
        return charArraytoString(outputArray);
    }


    public static String charArraytoString(final char[] inputArray) {
        String finalResult = new String();
        for (char c : inputArray) {
            if (c != '\u0000') {
                finalResult = finalResult + ((Character) c).toString();
            }
        }
        return finalResult;
    }
}