vendredi 6 juillet 2018

If condition in android not working properly. Can anyone guide me?

The conditions i write inside the if block don't work well. For Example

    if (quantity > 1 ){
     quantity --;
     display (quantity);
    }
    else{
    ....
            }

if is true even when the quantity is 0 don't know why its doing so. Same for the less then condition if I write

    if(quantity <= 100){
     quantity += 1;
     display(quantity);
    }
    else {
    ...
    }

This block of code gets the value to 101 and prints it to the screen then stops incrementing.

Don't know what's wrong, I am using latest Android Studio and Java Jdk and this is happening in the logics in .java file.

Any way to solve it ?

Aucun commentaire:

Enregistrer un commentaire