I am needing to check if a string does NOT contain any of these string possibilities:
MNC
BRA
LEB
MAR
RVC
WAY
GLZ
WWW
HYB
My current code :
if(selectedLocation.equals("OTH"))
{
if(!currentClassLocation.equals("MNC") &&
!currentClassLocation.equals("BRA") &&
!currentClassLocation.equals("LEB") &&
!currentClassLocation.equals("MAR") &&
!currentClassLocation.equals("RVC") &&
!currentClassLocation.equals("WAY") &&
!currentClassLocation.equals("GLZ") &&
!currentClassLocation.equals("WWW") &&
!currentClassLocation.equals("HYB"))
{
//Awesome, I need this string! I operate on it here.
}
}
Long story short, I can’t use a for-loop. Is there a way I can check if the string doesn’t contain any of these without iteration?
Use a
HashSet: