Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import java.util.stream.IntStream;
  2.  
  3. interface LambdaOperation {
  4. double performOperation(double n);
  5. }
  6.  
  7. public class SixthExercise {
  8. public static void main(String[] args) {
  9. LambdaOperation lambdaOperation = n -> (int) Math.pow(2, n);
  10.  
  11. System.out.println("Power of base two to third(n) exponent: " + lambdaOperation.performOperation(3));
  12.  
  13. IntStream
  14. .rangeClosed(0, 20)
  15. .boxed()
  16. .forEach(it -> System.out.println("Value no: " + it + " is: " + (int) lambdaOperation.performOperation(it)));
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement