@Override
    public void swap(List<Integer> list, int left, int right) {

        // checking input parameter for null
        if (list == null) {
            throw new IllegalArgumentException("swap error: disallowed value");
        }

        int temp = list.get(left);
        list.set(left, list.get(right));
        list.set(right, temp);
    }