S
S
Surface-ketch2020-12-01 19:10:21
Java
Surface-ketch, 2020-12-01 19:10:21

Why does comparing different values ​​of a value type return true?

Good day. Why does comparing different values ​​of a value type return true in this case? Specifically, on line 100, the condition always returns true, although it is clear that they are not equal.

Screenshots of debug
Скрин раз 5fc669fa606f6664639671.png

Скрин два5fc66a22b3c15394836810.png

piece of code
@Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                int int1 = editText.getText().toString().length();
                int int2 = currentWord.getEnglishWord().toString().length();

                String string1 = editText.getText().toString();
                String string2 = currentWord.getEnglishWord();

                if(string1.length() == string2.length());
                {
                    if(editText.getText().toString().equals(currentWord.getEnglishWord()))
                    {
                        Toast.makeText(getContext(), "WIIIIIIN!!!!", Toast.LENGTH_SHORT).show();
                    }else
                    {
                        int g =int1 + int2;
                        string1 +=string2;
                        Toast.makeText(getContext(), "LOOOOSE!!!!", Toast.LENGTH_SHORT).show();

                    }
                }
            }


PS Through Integer.equals the same thing, all the time true, as if there is no condition at all on line 100.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2020-12-01
@Surface-ketch

Why do you need a semicolon at the end of the if statement ?!!!!
You understand that in this case your comparison operator is simply wasted!

A
al_gon, 2016-11-10
@kyklaed

find_allor findAll?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question