[OT] RE: switch statement

2003-06-06 Thread Chen, Gin
Javascript does. Switch in java also works with chars. -Tim -Original Message- From: Yee, Richard K,,DMDCWEST [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2003 11:48 AM To: 'Struts Users Mailing List' Subject: RE: switch statement Keith, The switch statement doesn't work with all p

[OT] RE: switch statement

2003-06-06 Thread David Graham
If the value you're looking up in the database is ultimately an int and you're just using String names to make the code maintainable, you could use a Map to map the names to the ints. That would get rid of all the switches and ifs. David Because having descriptive values for parameters helps

[OT] RE: switch statement

2003-06-06 Thread David Graham
If the parameter values all have different first characters you could extract the first char and use that in your switch. David The reason I wanted to do this was to make my Action classes cleaner. I send a parameter to the Action to determine which item to pull from a database, then forward to

[OT] Re: switch statement

2003-06-06 Thread David Graham
You can't use Strings in switch statements. AFAIK, only ints and chars are allowed David Hey everyone, This is more of a Java question than a Struts question, I hope you all don't mind. I'm just wondering if there is any way to use a String for a switch statement, or if you are restricted to