User Tools

Site Tools


java:control_structures:switch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:control_structures:switch [2013/04/10 15:45]
94.223.12.247 created
java:control_structures:switch [2024/02/16 01:03] (current)
Line 1: Line 1:
 ====== switch ====== ====== switch ======
 +
 +The switch statement is a multi-select control structure. An expression is evaluated once and compared to 'constants'. In case of equality, the 'statements' that come after the 'constant' are processed. In switch 'statements' can only ordinary data types (ie, 'int', 'long', char, short, etc.) can be used.
 +
 <code java> <code java>
-switch (variable) { +switch(expression) 
-        +
-       case comparison_valuecommand; +   case constant1: 
-       break; +       statements 
-        +   break; 
-       default: command; +  
-     }+   case constant2
 +       statements 
 +   break; 
 +  
 +   case constantn: 
 +       statements 
 +   break; 
 +  
 +   default: 
 +       statements 
 + 
 </code> </code>
  
Line 48: Line 62:
  
 === output === === output ===
-    Please enter a note: 4 +    Please enter a note: 2 
-    sufficient+    good

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
java/control_structures/switch.1365601513.txt · Last modified: 2024/02/16 01:02 (external edit)

Impressum Datenschutz