How to correct what is red? [closed]

-3

I'm a beginner and I can not fix what's in the red in the image when I switched to the changed color code but in Android Studio so

public class MainActivity extends Activity {                                 

    private ViewManager l;                                                   

    @Override                                                                
    protected void onCreate(Bundle savedInstanceState) {                     
        super.onCreate(savedInstanceState);                                  
        setContentView(R.layout.activity_main);                              


        String s = "";                                                       
        for (int i = 1; i <= 45; i +=6) {                                    
            TextView t = new TextView(this);                                 
            t.setText(s);                                                    
            l.addView(t);                                                    
        }                                                                    
        int x = 2;                                                           
        do {                                                                 
            Button b = new Button(this);                                     
            b.setText(x);                                                    
            l.addView(b);                                                    
            if (x == 7 && x == 13 && x == 19)                                
                continue;                                                    
        } while (x <= 24);                                                   


    }                                                                        
}                                                                            
    
asked by anonymous 05.12.2016 / 17:47

1 answer

1

It has gone red because it does not have the variable x to have 3 values at the same time, you are using the && :

if (x == 7 && x == 13 && x == 19)

It would be like saying x has to be equal to 7, 13 and 19 at the same time, it's as if IDE is giving you a hint that you'll never be able to get into that% / p>

I believe you want to be the "OU", variable if has either 7 or 13 or 19, if it does this, do so:

if (x == 7 || x == 13 || x == 19)

Learn the difference of operators in link

---------------------------------------------------------------
| Tipo            |  Operadores                               |
---------------------------------------------------------------
| Sufixais        |   expr++ expr--                           |
| Prefixais       |   ++expr --expr +expr -expr ~ !           |
| Multiplicativos |   * / %                                   |
| Aditivos        |   + -                                     |
| Shift Binário   |   << >> >>>                               |
| Comparativos    |   < > <= >= instanceof                    |
| igualdade       |   == !=                                   |
| Bit-aBit E      |   &                                       |
| Bit-aBit XOU OR |   ^                                       |
| Bit-aBit OU OR  |   |                                       |
| Lógico E        |   &&                                      |
| Lógico OU       |   ||                                      |
| Ternário        |   ? :                                     |
| Atribuição      |   = += -= *= /= %= &= ^= |= <<= >>= >>>=  |
---------------------------------------------------------------
    
05.12.2016 / 18:21