Free Puzzle Questions with Answer using Java, C#, JavaScript and PHP

Java Quiz - Remove Duplicate Item

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package removeduplicateitem;

/**
 *
 * @author Bereket
 */
public class RemoveDuplicateItem {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int[] sampleData = {12,32,1,3,6,2,12,3,1,2};
        
        int[] result = RemoveDuplicate(sampleData);
        
        for(int i=0;i < result.length; i++){
            System.out.println(result[i]);
        }
    }
    
    static int[] RemoveDuplicate(int[] givenArray){
        if(givenArray == null || givenArray.length == 0){
            return givenArray;
        }
        else{
            int[] output = new int[givenArray.length];
            int counter = 0;
            
            boolean isDupicate = false;
            for(int i=0; i < givenArray.length; i++){
                isDupicate = false;
                for(int j=0; j < output.length; j++){
                    if(givenArray[i] == output[j]){
                        isDupicate = true;
                        break;
                    }
                }
                
                if(isDupicate == false){
                    output[counter] = givenArray[i];
                    counter++; // counter = counter + 1;
                }
            }
            
            if(counter == output.length){
                return output;
            }
            else{
                int[] filteredOutput = new int[counter];
                
                for(int x=0; x < filteredOutput.length; x++){
                    filteredOutput[x] = output[x];
                }
                
                return filteredOutput;
            }
        }
    }
    
}