Created
April 18, 2018 16:37
-
-
Save iamcrypticcoder/d981daca9051d193bbac1b2ece3abe35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ConsumerDemo { | |
static class Point { | |
Double x, y; | |
public Point(Double x, Double y) { | |
this.x = x; | |
this.y = y; | |
} | |
} | |
public static void main(String... args) { | |
Point point = new Point(1.0, 2.0); | |
Consumer<Point> pointPrinter1 = (p) -> System.out.printf("x = %f, y = %f\n", p.x, p.y); | |
Consumer<Point> pointPrinter2 = (p) -> System.out.printf("(%f, %f)\n", p.x, p.y); | |
pointPrinter1.accept(point); | |
pointPrinter2.accept(point); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment