Object Oriented Software Engineering   View all facts   Glossary   Help
subject > programming language construct > statement > decision-making statement > Java decision-making statement > Java switch statement
Next Java decision-making statementJava try catch statement    UpJava decision-making statement    Previous Java decision-making statementJava if statement   

Java switch statement
subjectfact 
Java switch statementcan be avoided by using polymorphismlink: chapter2section2.8.html#741, 2001-08-30 14:56:21.0
has form
switch(primitiveVariable)
{
case value1:
// statements to execute if variable equals value1
break;
case value2:
// statements to execute if variable equals value2
break;
...
default:
// statements to execute if none of the above is true
break;
}
link: chapter2section2.8.html#737, 2001-08-30 14:56:21.0
is a subtopic of The Basics of Java2001-08-30 14:56:21.0
is a kind of Java decision-making statement2001-08-30 14:56:21.0
Java statementis terminated by a semicolon2001-08-30 14:56:21.0
statementshould be not more than one line long if possible2001-08-30 14:57:47.0