Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. public class Point {
  2. private final int x, y;
  3. private final Lazy<String> lazyToString;
  4. public Point(int x, int y) {
  5. this.x = x;
  6. this.y = y;
  7. lazyToString = new Lazy<>();
  8. }
  9. @Override
  10. public String toString() {
  11. return lazyToString.getOrCompute( () -> "(" + x + ", " + y + ")");
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement