switch statement

2 topics · 2 sources

Technology› Programming

Java

A selection statement in which the value of an arithmetic expression {expression!arithmetic} is compared for a match against different case labels. If no match is found, the optional default label is selected For instance

 switch(choice){ case 'q': quit(); break; case 'h': help(); break; ... default: System.out.println("Unknown command: "+choice); break; } 

Technology› Programming

Perl

A program technique that lets you evaluate an "expression" and then, based on the value of the expression, do a multiway branch to the appropriate piece of code for that value. Also called a "case structure", named after the similar Pascal construct. Most switch statements in Perl are spelled for. See "Basic BLOCKs and Switch Statements" in perlsyn.

Cite this definition

APA
MLA
Chicago