Isaac Lewis
Isaac Lewis

Reputation: 1199

Checking if long is in array

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!

Upvotes: 2

Views: 2735

Answers (2)

Bala R
Bala R

Reputation: 108957

Try

!Arrays.asList(d).contains(sq);

Upvotes: 7

Chesrae
Chesrae

Reputation: 435

Look at the static methods in java.util.Arrays. Your array will need to be sorted for the binarySearch() to work.

Upvotes: 0

Related Questions