I’m using JSP where the user selects a background. The number of times each past selection has been made will be recorded. Example: green was used twice, yellow was used once, red was used five times. I wanted to use an associative array where the colour is the key and the value is the number of times it was used. But Java doesn’t have associative arrays so I guess my next best option is a normal array?
Also, how do I pass this information from one page to the next? I was thinking of using hidden fields but that wouldn’t work with an array.
As Bozho said, use a
HashMap<Color, Integer>. For updating the count you’d have to get the integer from the map, increment and put it back to the map.You might store that map in the user’s session.