summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing1003.java
blob: d9b9ea94030c64f2e6b834fd08fb0519b5297a4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Listing1003.java */

public class Listing1003
{
  public static void printTable(DoubleMethod meth)
  {
    System.out.println("Wertetabelle " + meth.toString());
    for (double x = 0.0; x <= 5.0; x += 1) {
      System.out.println(" " + x + "->" + meth.compute(x));
    }
  }

  public static void main(String[] args)
  {
    printTable(
      new DoubleMethod() 
      {
        public double compute(double value)
        {
          return Math.sqrt(value);
        }
      }
    );
  }
}