[Logo]
Forums Register Login
What's wrong with this If statement
Hi,
I'm going crazy with this statement. I am getting a String returned from a method and then checking if it isn't certain value. If it's not, then print something. Here's the code:

To my understanding, the above if statement checks to see if cclass is not equal to II or IC and then, prints the statement. But, it's printing the statement even if cclass is IC. I'm really confused. Could someone please tell me what i'm doing wrong. Thanks.
[ March 15, 2006: Message edited by: jay donald ]
Code looks fine. Are you sure it's a capital letter "i", and not a vertical bar (|) or lower case letter "L" (l) ?
I agree, the code looks fine.

Try printing out the value of each individual expression - cclass.equalsIgnoreCase("II") , cclass.equalsIgnoreCase("IC") and the expression (cclass.equalsIgnoreCase("II") || cclass.equalsIgnoreCase("IC")) .
Hi,
Thanks for your response. Yeah It's IC. Ok, this is what i did:

and guess what ..it's printing false when it should be printing true. Man, i'm going nuts over here.
Is cclass a String?
Hey Ernest,
yes, it's a String (that's why im using equals()). THis class is part of a web application and i'm using test enviornment of WSAD 5.1.
[ March 15, 2006: Message edited by: jay donald ]
I finally figured it out. The String i was getting back from the method is a column in a table with a char datatype. So, it was adding a "blank" to the string since the length of that column is defined as 3. So, trim() did the trick. Thanks for your help.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 23, 2017 00:56:53.