Checking if long is in array
-
14-11-2019 - |
Question
I need to make sure that a certain long value isn't in an array. But for some reason, this isn't working...
!d.toString().contains(sq.toString());
I am sure I am getting something really backwards... but I can't figure out what!
Solution
Try
!Arrays.asList(d).contains(sq);
OTHER TIPS
Look at the static methods in java.util.Arrays. Your array will need to be sorted for the binarySearch() to work.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow