remove object from an array java
<p>My practice problem says to"this method returns an array that has the elements of the specified</p>

<pre><code> // array of Objects, with the Object at the specified index removed.

    // the returned array should be smaller by one and have all elements

    // in the same relative location to each other. YOU MAY NOT USE

    // A LIST :)

Object[] remove(int index, Object[] arr){"
</code></pre>

<p>I have come up with this so far, and I'm not entirely sure it works. Can you guys please take a look and give me some feedback on how to fix it so I can do this "remove" properly.</p>

<pre><code>public static remove(int index, Object[] arr){
int counter = 0;
int temp = 2;
int[] arr = {1, 2, 3, 4};
int[] second = new int[arr.length-1];

    for(int i=0; i&lt; arr.length;i++){
        if(i != temp){
            second[counter] = arr[i];
            counter ++;

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