Play audio slide show -- Keyboard shortcut: 'x'  Lecture overview -- Keyboard shortcut: 'u'  Previous page: Kommandoer til udvælgelse i Java (1) -- Keyboard shortcut: 'p'  Next page: Kommandoer til gentagelse i Java (1) -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home  Play sound for this slide -- Keyboard shortcut: 'y'    De ikke objekt-orienterede dele af Java - slide 18 : 39

Kommandoer til udvælgelse i Java (2) 

switch (udtryk) {
  case værdi1: kommando-liste1
  case værdi2: kommando-liste2
  ...
  default: kommando-liste3
}
 

SwitchDemo1.javaEt program der demonstrerer switch i Java.
 

SwitchDemo2.javaSwitch uden breaks.
 

Go to exerciseOmformning af if til switch