[Java] Conditional branch

if statement

The if statement judges the evaluation (comparison) result such as a numerical value or a character string. If the evaluation result is "true", the processing in the if block is executed. If the evaluation result is "false", combine the else statements.

if(Conditional statement) {
     //Conditional statement is true(true)Is executed here at
}
else {
     //Conditional statement is false(false)Is executed here at
}

It is necessary to judge the condition in order to branch the process such as if statement. Judgment is called "evaluation".

Relational operator

関係演算子.png

Logical operator

drow.io.png

switch statement

The switch statement allows you to specify the code to execute if the specified variable takes a specific value. Variables are specified in switch, and conditional values are specified in case. You can specify the code to execute after the case value :. The code block runs until break.

switch(variable) {
case value 1:
case value 2:
     //This is executed when the value is 1 or 2.
     break;
case value 3:
     //This is done when the value is 3
     break;
default:
     //Value 1, 2,This is done when neither of 3 is
     break;               
}          

Recommended Posts

Java conditional branch
java conditional branch
[Java] Conditional branch
Ruby conditional branch processing
java learning (conditional expression)
[Java] Branch and repeat
Swift conditional branch statement summary
Java study # 7 (branch syntax type)
Java
java (conditional branching and repetition)
Java
Conditional branch with helper method
[Ruby] conditional branch if statement
[Java] Branch enum with switch statement
Java study # 4 (conditional branching / if statement)
Java learning (0)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
[Java] Module
Studying Java ―― 9
Java scratch scratch
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
Java string
java (array)
Java static
Java serialization
java beginner 4
JAVA paid
Studying Java ―― 4
Java (set)
java shellsort
[Java] compareTo
Studying Java -5
java reflexes
java (interface)
Java memorandum
Java array
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
[Java] Personal summary of conditional statements (basic)
[Java] Inheritance
FastScanner Java
Java features
java beginner 3
Java memo
java (encapsulation)