Skip to content Skip to sidebar Skip to footer

How To Compare Values Stored In List With A Long Value?

I'm retrieving some long values and storing it in List l. Here is the logged out value of List l: D/lng: [2197, -1007, 4003] Then, I'm trying to compare i

Solution 1:

You made a list with Long, both List and Long are not primitive data types. In your question you are comparing primitive and non primitive data types, for comparison both sides of a comparator should be of same data types.

What you are doing:

if (l.get(i) <= 900)

Here l.get(i) returns a Long value where as 900 is integer value.

What you should do:

Simply compare your l.get(i) with Long by doing 900L

if (l.get(i) <= 900L)

Or

if (l.get(i) > 900L)

Post a Comment for "How To Compare Values Stored In List With A Long Value?"