# Questions tagged as 'else'

4

## IF, ELSE IF, ELSE or IF IF IF. When to use, what's the difference?

It's a very basic question, but it intrigues me a lot. See the code below: var bola = "redonda"; if(bola == "comestivel") return comer(); if(bola == "liquida") return beber(); if(bola == "redonda") chutar(); Now see the same with if ,...
4

## What good practice when throwing exception within if?

What is the best practice in this case, to use else even though you know that if will throw an exception or not? option 1 (with else ): if (condicao){ throw new RuntimeException("Mensagem"); }else{ System.out.println("Não deu exce...
2

## There is an "else while"

Is there any way for me to do this? While it's one thing to do that, then when is it another to do that? For example: var i = 0; while(i < 5){ //faça isso i++; } else { //faça aquilo } Is it possible to do this somehow?    ...
3

## Omitting the else is a good idea in some cases, or not? [closed]

I ask myself this question every time I'm coding, because I always worry about leaving my code understandable to other programmers who will be looking at it - and myself, because maybe I will not remember what I did there. Would it be a good...
2

## Question and answer with if and else in Java

No matter what I answer, both "Yes" and "yes" only show ELSE . Where am I going wrong? package saudacao; import java.util.*; public class Saudacao { public static void main(String[] args) { System.out.println("Ola, bom dia, v...
2

## Display the largest and smallest values between two integers when they are different from each other

I can not display the lower and upper values.    Make an algorithm that reads two numbers and indicates whether they are the same or, if different, show the largest and smallest in this sequence. int V1,V2; printf("Valor 1 :"); scanf("%d"...
2

## PHP parametric functions

I'm new to php and I'm creating a comparison of box sizes, and for that I'd like to put inside a function but I do not know which parameter to put inside the function's relatives. Someone could help me, Thanks. <?php include("caixa.php");...
4

## JavaScript function with NaN error

Hello. I'm encountering a problem executing this formula, because the final answer is given as NaN. In a simplified way to explain the code, it works like this: there are two groups of three variables, and depending on the value you assign...
1