Questions tagged as 'if'

1
answer

if with a matches or several comparisons?

Considering that I have a variable of type String tipoResidencia that will never be null, and that I need to run a test, the default solution is this: if (tipoResidencia.equals("CASA") || tipoResidencia.equals("PREDIO") ) But if I wa...
asked by 14.08.2015 / 22:14
3
answers

"== true" is it useful for anything? Is it better "!" Or "== false"?

Is == true useful for scans, or is it completely useless? It is best to use ! or == false . Example: if (pessoa.estaMorta() == false) .... if (!pessoa.estaMorta()) .... if (pessoa.estaViva() == true) .... if (pessoa....
asked by 15.07.2018 / 16:37
1
answer

Javascript performance: switch or if nested?

Which of the two alternatives provides the best performance in Javascript: switch or if nested? if { ... } else { if { ... } else { if { ... } else { ... } } } or switch(expression) { case n:...
asked by 20.06.2014 / 18:14
1
answer

Retry user and password attempts

I wanted a program that checks the user and password, if it was correct to display a message, if it repeated the check and if the attempts were equal to 3, it showed the limit message of attempts reached. #include <stdio.h> #include <...
asked by 02.05.2016 / 13:32
3
answers

How to check if an item is contained in an array?

What am I doing wrong in this if ? if (angular.uppercase(nome[id]) in ['A', 'E','I', 'O', 'U']) { .... } If I only do this, it works. But I'll have to repeat it to others. if (angular.uppercase(nome[id]) == 'A'){ ..... }...
asked by 25.12.2015 / 20:57
4
answers

Should I use two IF's or an operator?

What is the best practice for checking two conditions? In the example I am going to give, these are not very long checks, but what is the best practice and what is the difference? (it happened to me that I found myself having a if huge...
asked by 29.08.2018 / 12:33
1
answer

What is the purpose of the while (* variable) and if (! * variable) in the "while" and "if" statements?

In the Code Review there is a implementation of a simply linked list
asked by 08.11.2016 / 00:02
4
answers

Why an if can be redundant?

Using a method that returns a boolean the system would determine whether a number is positive or negative. So I did it this way: public boolean isPositive(float num) { boolean positive; if (num >= 0) { positive = tru...
asked by 19.04.2016 / 21:02
2
answers

The if statement in java is not working inside a method

I'm a beginner and I'm not getting my code to work as expected with the if / else. I'm using this command within a method and doing it as follows: private boolean AutentificaSenha(String s) { this.aSenha = s; boolean cond = this.s...
asked by 04.07.2015 / 00:04
2
answers

Alternative for Switch within Switch

I'm making a decision structure that depends on more than one variable, but readability and maintenance using if or switch are bad. What alternatives do I have for this case? Example of% nested% nested: switch (var1) {...
asked by 01.06.2016 / 00:58