OO Programming with Java


Advanced Concepts

  1. Function already exists in java.util.function package:
import java.util.function.*;
public class Funs {
  public static void main(String[] args) {
    Function<Integer,Integer> abs = new Function<Integer,Integer>() 
      { public Integer apply(Integer x) { return (x>=0)?x:-x; }};
    System.out.println(abs.apply(-3));
  }
}

Take a look at the function package and try to identify:


5 - 17