package algus; import java.util.Arrays; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; public class ArvuProov1 { public static double arvuta(double arv, ArvuTootleja tootleja) { return tootleja.tehe(arv); } public static void main(String[] args) { double a = 3; System.out.println(arvuta(a, new Kahekordistaja())); System.out.println(arvuta(a, x -> x * x)); Function tehe1 = (b) -> b * b * b; System.out.println(tehe1.apply(a)); Consumer pyydja1 = (b) -> { System.out.println("saabus " + b); }; Arrays.stream(new Double[] { 3.0, 7.0, 6.0 }).forEach(pyydja1); Predicate kontrollija1 = b -> b < 5; Arrays.stream(new Double[] { 3.0, 7.0, 6.0 }).filter(x -> x>6) .forEach(System.out::println); Arrays.stream(new Double[] { 3.0, 7.0, 6.0 }).filter(kontrollija1) .forEach(pyydja1); } }