I have a class that looks like this:
public class Items {
String uselessText;
public static final Item COW = new Item("text", 0);
public static final Item CAT = new Item("abc", 1);
public static final Item DOG= new Item("wow", 2);
...SO on
public void search(String search) {
for(every Item in this Class) {
if(item.textString == "abc") {
//DO SOMETHING
}
}
}
Is this possible? And no thanks I do not want to do an Array (because I have over 100 Item and I want them static access)
Any idea?
Cheers
If you can list all of the possible instances of the class at compile time, use an
enum.