Remove duplicate elements from array along with element using Java 1.7
Use the right tools

You are on the right track to use Collections.frequency, as it does a lot of the plumbing for you

Start simple

The basic idea is to create a new list, unique that will contain the numbers that are unique. 

This is the piece of code that will do all the hard work (but is not optimized yet!).

ArrayList&lt;Integer&gt; uniqueNumbers = new ArrayList&lt;&gt;();

for (Integer number : numbers) {
    if (Collections.frequency(numbers, number) == 1) {
        uniqueNumbers.add(number);
    }
}


Now you only need to convert your input array to an numbers ArrayList and convert the resulting uniqueNumbers list back to an array.

Then optimize

If you care about performance, you will probably want to skip number that you have already checked and know that they are non unique. You can do this with a Set&lt;Integer&gt;.

Set&lt;Integer&gt;  nonUniqueNumbers   = new HashSet&lt;&gt;();
ArrayList&lt;Integer&gt; uniqueNumbers = new ArrayList&lt;&gt;();

for (Integer number : numbers) {

    if (!nonUniqueNumbers.contains(number)) {
        if (Collections.frequency(numbers, number) == 1) {
            uniqueNumbers.add(number);
        }
        else {
            nonUniqueNumbers.add(number)
        }
    }
}


More room for performance

To increase the performance, you only want to scan each input element once; this can for example be done like this:

public static Collection&lt;Integer&gt; getUniques( Collection&lt;Integer&gt; input )
{
    Set&lt;Integer&gt; uniques = new HashSet&lt;&gt;();
    Set&lt;Integer&gt; nonUniques = new HashSet&lt;&gt;();
    for ( Integer i : input )
    {
        //if i is in the nonUnique set, we already have it twice, 
        //no need to do anything with it anymore
        if ( nonUniques.contains( i ) )
        {
            continue;
        }
        else
        {
            //either we never saw i, or we have seen it once.
            //if we saw it once, it will be in the uniques.
            if ( uniques.contains( i ) )
            {
                //if it was in the uniques , this is the second time we encountered it.
                //remove it from the uninques and put it in the nonUniques
                uniques.remove( i );
                nonUniques.add( i );
            }
            else
            {
                //if we never saw i, it should be in the uniques set (for now)
                uniques.add( i );
            }
        }
    }
    return uniques;
}