How to check if an element is in an array?# Java - 爪哇娇娃
y*o
1 楼
In ArrayList, we can use contains(Object o) which returns a boolean value.
How about an array of primitive integers? In Python, we can do
if x in myList:
print "I got you!"
Any easy way to do the same in Java? I have always been wondering about
this.
Thanks.
How about an array of primitive integers? In Python, we can do
if x in myList:
print "I got you!"
Any easy way to do the same in Java? I have always been wondering about
this.
Thanks.