hw/hw2/hw2/Percolation.java
private void validate(int p) {
        int n = grid.length;
        if (p < 0 || p >= n) {
            throw new IndexOutOfBoundsException("index " + p + " is not between 0 and " + (n - 1));
        }
    }
/**
     * private helper method
     *
     * validate that p is a valid index
     */
private helper method
validate that p is a valid index
private helper method validate that p is a valid index
private void validate(int p) {
        int n = grid.length;
        if (p < 0 || p >= n) {
            throw new IndexOutOfBoundsException("index " + p + " is not between 0 and " + (n - 1));
        }
    }
private void validate ( int p ) { int n = grid . length ; if ( p < 0 || p >= n ) { throw new IndexOutOfBoundsException ( "index " + p + " is not between 0 and " + ( n - 1 ) ) ; } }
private helper method
 validate that p is a valid index
private helper method validate that p is a valid index