Skip to content Skip to sidebar Skip to footer

If Statement Not Working For Android Programming

I am trying to create a type of triangle app for my homework but when I tried to use if statement in java, for some reason, when I click on the 'Generate Button', it keeps on showi

Solution 1:

click on the "Generate Button", it keeps on showing the " Scalene Triangle: No Congruent Sides"

Because you are getting all EditText Values before onClick of "Generate Button".

To fix issue call EditText.getText() from onClick of Button


Solution 2:

You are comparing String references, not numbers. You should use Integer.parseInt (or Float.parseFloat if you allow float values) to convert the text entered by the user before doing any comparisons.


Post a Comment for "If Statement Not Working For Android Programming"