Guest User

Untitled

a guest
Oct 20th, 2019
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.function.*;
  2.  
  3. public class NextEven {
  4. public static void main(String... args) {
  5.  
  6. LongUnaryOperator nextEven =
  7. x -> ((++x & 1) == 0) ? x : ++x;
  8.  
  9. System.out.printf("%d -> %d\n", 2, nextEven.applyAsLong(2));
  10. System.out.printf("%d -> %d\n", 317, nextEven.applyAsLong(317));
  11.  
  12. nextEven = a -> (a + 2) ^ ~(a + 1) + ;
  13.  
  14. System.out.printf("%d -> %d\n", 2, nextEven.applyAsLong(2));
  15. System.out.printf("%d -> %d\n", 317, nextEven.applyAsLong(317));
  16. }
  17. }
RAW Paste Data