I have an ArrayList which has the following Strings in it: [name, age, gender, salary]
. Is there a way I can use the values in my ArrayList to be case expressions? The obvious answer would be no, since case expressions must be constant expressions. However, I am wondering what the best way to do this would be if I can't use switch/case.
To be clear, the intended behavior is something like this:
switch (parameter) {
case XXX:
// some code here
case YYY:
// some code here
}
I want XXX to be name, and YYY to be gender, which both come from the ArrayList. I'm open to using if/else if this can't be done with switch/case. How can I do something like this? Thanks.