Select 3 items or 4 items out of 8 items : I am trying to get 3 or 4 items out of an array of 8 numbers (1-8). If i try to print the array of the 3 or 4 items. Most of the trys it worked but some times I only get some numbers and a 0 which isn't in the array. Like this [2, 5, 3, 0]. 

    private int[] randomPeople() {
        int[] result = {0, 0, 0, 0};
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8};
        return getRandomPeople(result, arr);
    }

    private int[] getRandomPeople(int[] result, int[] arr) {
        int number;
        for (int i = 0; i < result.length; i++) { 
            number = (int) (Math.random() * arr.length + 1);
            for (int j = 0; j < result.length; j++) { 
                if (number == result[j]) { //check if the random number is already in the list --> new random int
                    j = 0;
                    number = (int) (Math.random() * arr.length + 1);
                }
            }
            for (int j = 0; j < arr.length; j++) { // adds the number to the new array and delete it in the old
                if (number == arr[j]) {
                    result[i] = number;
                    arr = searchDelete(arr, number);
                }
            }
        }
        System.out.println(Arrays.toString(result));
        return result;
    }


This method is for deleting the searched ID. You have to hand over an array and the int which should be deleted.

    private int[] searchDelete(int[] arr, int SRID) {
        int pos;
        for (pos = 0; pos < arr.length - 1; pos++) {
            if (arr[pos] == SRID)
                break;
        }
        while (pos < arr.length - 1) {
            arr[pos] = arr[pos + 1];
            pos++;
        }
        int[] arr2 = new int[arr.length - 1];
        System.arraycopy(arr, 0, arr2, 0, arr.length - 1);

        return arr2;
    }