Results 1 to 2 of 2
  1. #1
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default Problems with collection

    I need to create a "table" of values. The columns are

    Object, int, int

    this table will have no more than 100 rows at any time
    I have reviewed collections such as HashMap, but it seems you can only have two 'columns' and the primitives would have to be converted to Integer Objects

    Is there a collection I can use that allows me to define three columns with different data types?

  2. #2
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default

    you can wrap your Object and int in a value object:
    check it:
    Java Code:
    public class ValueObject {
      private Object obj;
      private int first;
      private int second;
    
      public ValueObject(Object obj, int first, int second) {
        this.obj = obj;
        this.first = first;
        this.second = second;
      }
      public Object getObject() {
        return object;
      }
      public int getFirst() {
        return first;
      }
      public int getSecond() {
        return second;
      }
    }

Similar Threads

  1. How to use Collection in Spring
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-29-2008, 12:45 PM
  2. Garbase Collection
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-30-2007, 09:37 AM
  3. How to use Collection in Springs
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 09-26-2007, 08:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •