Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Balls {
- private static int compare(Integer o1, Integer o2) {
- if (o1 % 2 == 1) {
- return 1;
- }
- if (o1 % 2 != 1) {
- return -1;
- }
- return 0;
- }
- public static void main(String[] args) {
- Map<Integer, Integer> balls = new TreeMap<Integer, Integer>(Balls::compare);
- for (int i = 0; i < 20; i++) {
- balls.put(i + 1, (int) (20 + Math.random() * 40));
- }
- System.out.println(balls.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement