Square.java


Below is the syntax highlighted version of Square.java from §3.3 Designing Data Types.


/******************************************************************************
 *  Compilation:  javac Square.java
 *  Execution:    
 *
 *  A function that implements the Function interface.
 *
 ******************************************************************************/

public class Square implements Function {
    public double evaluate(double x) {
        return x*x;
    }
}


Copyright © 2000–2017, Robert Sedgewick and Kevin Wayne.
Last updated: Fri Oct 20 14:12:12 EDT 2017.