I want to know if there's a way of doing something like this in Java :
if(word in stringArray) {
...
}
I know I can make a function for this but I just want to know if Java has already something for this.
Thank you!
Answer
There are many collections that will let you do something similar to that. For example:
With Strings
:
String s = "I can has cheezeburger?";
boolean hasCheese = s.contains("cheeze");
or with Collections
:
List listOfStrings = new ArrayList();
boolean hasString = listOfStrings.contains(something);
However, there is no similar construct for a simple String[]
.
No comments:
Post a Comment