I seem to be having a problem with a boolean test. when I use this code:
public boolean setPkg (String inPkg)
{
boolean isValid;
if ((inPkg.toUpperCase() != "A" ) || (inPkg.toUpperCase() != "B" ) || (inPkg.toUpperCase() != "C"))
isValid = false;
else
{
pkg = inPkg;
isValid = true;
}
return isValid;
}
It returns false on "A". However when I only test for "A":
...
if (inPkg.toUpperCase() != "A" )
isValid = false;
else
{
pkg = inPkg;
isValid = true;
}
return isValid;
...
it returns true.
what am I missing?
I have also tried to use multiple if else statements to test for A, B, or C and i get false for A. B and C dont get tested as an exception of my making is getting thrown.