Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.TreeSet;
- public class Main {
- public static class HeavyBox implements Comparable {
- public int weight;
- public HeavyBox(int weight) {
- this.weight = weight;
- }
- public void Print() {
- System.out.println(weight);
- }
- @Override
- public int compareTo(Object o) {
- return 1;
- }
- }
- public static void main(String[] args) {
- TreeSet<HeavyBox> Tree = new TreeSet<>();
- Tree.add(new HeavyBox(789));
- Tree.add(new HeavyBox(237));
- Tree.add(new HeavyBox(340));
- Tree.add(new HeavyBox(300));
- Tree.add(new HeavyBox(34));
- for (HeavyBox Box : Tree) {
- Box.Print();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement