March 7th, 2003, 08:57 AM
Problem with type?
I've new to jsp but have been forced to alter some pages.
I have a variable called dsu, I know the value of dsu is P25 but can't get this to work -
String dsu = item.getDefaultSalesUnitCode();
if(dsu == "P25")
I take it that dsu is a string? I've tried explicitly converting to a string but it makes no difference. Am I doing something wrong?
I'm new to this so hopefully it's something simple, any ideas?
March 7th, 2003, 09:36 AM
You have fallen into the classic beginner Java trap, dont feel bad it happens to everyone at the beginning. The == comparison operator should only be applied to numberic values or to test if two objects are the same, meaning they are references to the same object in memory. To compare Strings ALWAYS use the .equals() method so in this case the code should be
March 7th, 2003, 09:38 AM