If x in Java is in the array
•
Java
See English answers > how to determine why an array contains a particular value in Java? 25
myList = ["x","y","z"] myVar = "x" if myVar in x: print("your variable is in the list.")
How can I do this in Java?
Solution
If your array type is a reference type, you can convert it to an array with arrays Aslist (t...) and check whether it contains the element
if (Arrays.asList(array).contains("whatever")) // do your thing
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码