Java: how to create an array of tuples

data structuresjavajspsettuples

how can I create an array of tuples in jsp (java)
like
(a:1, b:2)
(c:3, d:4)

Best Answer

Create a tuple class, something like:

class Tuple {
    private Object[] data;
    public Tuple (Object.. members) { this.data = members; }
    public void get(int index) { return data[index]; }
    public int getSize() { ... }
}

Then just create an array of Tuple instances.