We were given this specification for the PercolationStats class:
public class PercolationStats {
public PercolationStats(int N, int T) // perform T independent computational experiments on an N-by-N grid
public double mean() // sample mean of percolation threshold
public double stddev() // sample standard deviation of percolation threshold
public double confidenceLo() // returns lower bound of the 95% confidence interval
public double confidenceHi() // returns upper bound of the 95% confidence interval
public static void main(String[] args) // test client, described below
}
and to implement mean() and stddev(), we had to use a special library that has a class called StdStats:
public final class StdStats {
private StdStats() { }
/* All methods declared static. */
}
I tried to write something like
public mean() {
return StdStats.mean();
}
but I get the following error:
Cannot make a static reference to the non-static method mean() from the type PercolationStats
Here is what's presumably generating it:
main() {
/* ... */
System.out.println("-- Summary --\n");
System.out.printf("mean\tstdev\t[lo\thi]\n\n");
System.out.printf("%1.3f\t%.3f\t%.3f\t%.3f", PercolationStats.mean(),
PercolationStats.stddev(), PercolationStats.confidenceLo(), PercolationStats.confidenceHi());
System.out.println("-- End --");
}
Is there a way to get rid of this error without changing the specification? I believe we're supposed to be able to make PercolationStats objects. Thanks for any help!