compairing a string to multiple strings

This is what I need to accomplish in seudocode

if (string != "this" or "that" or "this" or "that")

{

}

Id do it with 12 different or statements

if(string !="this" || string !="that" || ...etc){}

but Im wondering if there is a cleaner way to go about this.

[436 byte] By [Sparkkya] at [2007-11-26 22:48:44]
# 1
just as a clarification, I need to compair it to 12 different strings, thats why I mentioned doing it with 12 different statements.
Sparkkya at 2007-7-10 12:08:44 > top of Java-index,Java Essentials,New To Java...
# 2

String bla = "String4";

String[] checks = { "String1", "String2", "String3", ... };

boolean match = false;

for (int i = 0; i < checks.length; i++) {

if (checks[i].equals(bla)) {

match = true;

break;

}

}

if (match) {

}

Message was edited by:

Simeon

Message was edited by:

Simeon

Simeona at 2007-7-10 12:08:44 > top of Java-index,Java Essentials,New To Java...
# 3
Also, never use == or != to compare strings; use the equals() method instead.
uncle_alicea at 2007-7-10 12:08:44 > top of Java-index,Java Essentials,New To Java...