8 Replies Latest reply: Dec 12, 2007 7:05 PM by 807601 RSS

    TreeSet

    807601
      How do I sort through integers with TreeSet:

      I have the following code, but it doesn't work when two integers are equal. Is there any way around this?

      Examples of input:
      3 4 5
      5 2 5
      3 7 8
      99 99 99

      TreeSet t1 = new TreeSet();
              
              t1.add(num1);
              t1.add(num2);
              t1.add(num3);
      
              Iterator<Integer> it1 = t1.iterator();
              
              while (it1.hasNext()) {
                  side1 = it1.next();
                  side2 = it1.next();
                  side3 = it1.next();
              }