Possible Duplicate:
In Java, how can I test if an Array contains a certain value?
I have an array setup as follows:
Material[] blockedlevel1 = {
Material.mymaterialone, Material.mymaterialtwo
};
How do I see if a Material is in this array?
How about looking for it in the array?
for (Material m : blockedlevel1) {
if (m.equals(searchedMaterial)) { // assuming that equals() was overriden
// found it! do something with it
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With