This may be difficult to explain, but here goes:
I want to store 3 integers and a String to a Hashmap, so I can retrieve data from the map, but it turns out that hashmaps only allow 2 generic parameters instead of 4.
For example: HashMap <String> <Integer> <Integer> <Integer> (what I want to do)
but you can only use 2 parameters, as it seems: HashMap <String> <Integer>.
My best guess is that my idea cannot be done, if so please list the alternatives to handling something like this.
Make a new class which holds 3 Integer or maybe int.
class Triple {
    Integer i;
    Integer j;
    Integer k;
    Triple(Integer i,Integer j, Integer k) {
        this.i = i;
        this.j = j;
        this.k = k;
    }
}
and put this class to a map with the String.
HashMap map = new HashMap<String, Triple>();
map.put("keyString", new Triple(new Integer(1),new Integer(2),new Integer(3)));
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With