How do I take null spaces out of an array?
<p>I have to make a program that takes duplicate characters from an input array and prints out a new array with all unique characters. </p>

<p>It all works. Except when characters are taken out, it leaves an empty box at the end of that new array.</p>

<pre><code>public class Deleter {

public static void main (String[] args){
    Scanner keyboard = new Scanner(System.in);

    char[] initialInputArray = new char[15];

    System.out.println("How many characters do you wish to enter?");

    int size = keyboard.nextInt();

    while ( size &gt; initialInputArray.length ) {
        System.out.println("Error. Enter smaller number.");
        size = keyboard.nextInt();
    }
    if( initialInputArray.length &lt;= 15) {           
        for ( int counter = 0; counter &lt; size; counter++ ){             
            initialInputArray[counter] = keyboard.next().charAt(0);         
        }
        {

        }
    }

    deleteRepeats(initialInputArray, size); 
    //Comeback to print out array
    {
        for ( int helloWorld = 0 ; helloWorld &lt; size ; helloWorld ++)
            System.out.print(  initialInputArray[helloWorld] );
    }
}



//"deleteReapets" method begins, looking for repeated user inputs
public static char[] deleteRepeats (char[] methodArray, int sizeTwo) {

    if (sizeTwo == 0)
        return methodArray;

    if (sizeTwo == 1)
        return methodArray;

    int uniqueCharacter = 1; 
    //Start at the second entered character.

    for (int x = 1; x &lt; sizeTwo; ++x) { 
        int y;

        for (y = 0; y &lt; uniqueCharacter; ++y) {
            if (methodArray[x] == methodArray[y]) break; // break if we find duplicate.
        }


        if (y == uniqueCharacter) {
            methodArray[uniqueCharacter] = methodArray[x]; // add
            ++uniqueCharacter; // increment uniqueCharacter...[0,uniqueCharacter) is still "unique char list"

        }
    }
    while ( uniqueCharacter &lt; sizeTwo ) {
        methodArray[uniqueCharacter] = 0;
        uniqueCharacter++;

    }

            return methodArray;
}
</code></pre>

<p>}</p>
