mercredi 7 décembre 2016

if-else statement not working appropriately even when the conditions are true. Please see details

I'm trying to filter the content based on time and for that I have made an algorithm and checking the conditions by using if-else statements.

I'm fetching a list of long from database and storing it in List<Long> l. I'm logging out the values like this: Log.d("lng", String.valueOf(l));. Output: D/lng: [1926, -1278, 3732].

Then I'm trying to do the logic using these numbers fetched above, like this:

    final int size = l.size();

    for (int i = 0; i < size; i++){
        if (l.get(i) <= 900) {
           // do the logic
        } else {
           // show warning
        }

As you can see from the log output above, one of the lng from the output is <=900 and so the if statement should have been executed, but it didn't and instead else condition got executed!

Please let me know what am I doing wrong here?

Aucun commentaire:

Enregistrer un commentaire