Java   View all facts   Glossary   Help
syntactic unit > statement > control flow statement > decision making statement > if-else statement
Next decision making statementswitch-case statement    Updecision making statement    Previous decision making statementif statement   

if-else statement
subjectfact 
if-else statementcan omit braces if there is only one embedded statementadded by: JK, source: On To Java, 2001-10-19 11:36:52.0
has part else blockadded by: JK, source: On To Java, 2001-10-19 11:36:52.0
has syntax
if (boolean expression) {
if-true statement
else
if-false statement
}
added by: JK, source: On To Java, 2001-10-19 11:36:53.0
has example
int testscore; 
char grade;
if (testscore <= 90) {
grade = 'A';
} else if (testscore <= 80) {
grade = 'B';
} else {
grade = 'C';
}
added by: JK, source: Sun Java Tutorial, 2001-10-19 11:36:53.0
is a subtopic of Loops and Decision Making2001-10-19 11:36:53.0
is a kind of decision making statementadded by: JK, source: Sun Java Tutorial, 2001-10-19 11:36:53.0
decision making statementhas purpose to make a decision on which branch of code to follow in a program2001-10-19 11:36:35.0
statementis terminated by a semicolon    2001-10-19 11:37:57.0
should be not more than one line long if possible2001-10-19 11:37:57.0
syntactic unithas syntax rule
bold = mandatory
italic = non-terminal
normal font = optional
2001-10-19 11:38:04.0

Kinds of if-else statement :