How can I verify that an array of strings contain a certain string? [duplicate]
Internet of Things
IoT Frameworks
2 years ago
5
Star Rating
1
Rating
_x000D_
_x000D_
_x000D_
This question already has an answer here:_x000D_
_x000D_
_x000D_
How do I determine whether an array contains a particular value in Java?_x000D_
_x000D_
28 answers_x000D_
_x000D_
_x000D_
_x000D_
_x000D_
Given :
String[] directions = {"UP","DOWN","RIGHT","LEFT","up","down","right","left"};
String input = "Up";
How can I verify that an input from stdin is within the directions array or not ?
I can make a loop and check each item with input using equal ,but I'm looking for a more elegant way.
Regards,Ron
Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Take Quiz To Earn Credits!
Turn Your Knowledge into Earnings.