Best practice Java - String array constant and indexing it
- by Pramod
For string constants its usual to use a class with final String values. But whats the best practice for storing string array. I want to store different categories in a constant array and everytime a category has been selected, I want to know which category it belongs to and process based on that.
Addition : To make it more clear, I have a categories A,B,C,D,E which is a constant array. Whenever a user clicks one of the items(button will have those texts) I should know which item was clicked and do processing on that.
I can define an enum(say cat) and everytime do
if clickedItem == cat.A
....
else if clickedItem = cat.B
....
else if
....
or even register listeners for each item seperately.
But I wanted to know the best practice for doing handling these kind of problems.