Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1.  
  2. public class A {
  3. class Point implements Comparable<Point>{
  4. int x, y;
  5. Point(int x, int y){
  6. this.x = x;
  7. this.y = y;
  8. }
  9.  
  10. @Override
  11. public int compareTo(Point o) {
  12. if(this.x == o.x) return this.y - o.y;
  13. return this.x - o.y;
  14. }
  15. }
  16.  
  17. void solve(){
  18. Point[] a = new Point[2];
  19. a[0] = new Point(1, 2);
  20. a[1] = new Point(2, 1);
  21. }
  22.  
  23. public static void main(String[] args)
  24. {
  25. new A().solve();
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement