SHARE
TWEET

Untitled

a guest Jun 16th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Balls  {
  2.     private static int compare(Integer o1, Integer o2) {
  3.         if (o1 % 2 == 1) {
  4.             return 1;
  5.         }
  6.         if (o1 % 2 != 1) {
  7.             return -1;
  8.         }
  9.         return 0;
  10.     }
  11.     public static void main(String[] args) {
  12.         Map<Integer, Integer> balls = new TreeMap<Integer, Integer>(Balls::compare);
  13. for (int i = 0; i < 20; i++) {
  14.             balls.put(i + 1, (int) (20 + Math.random() * 40));
  15.         }
  16.         System.out.println(balls.toString());
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top