Java Switch Demo


SUBMITTED BY: Guest

DATE: June 25, 2014, 2:24 p.m.

FORMAT: Text only

SIZE: 661 Bytes

HITS: 724

  1. public class SwitchDemo {
  2. public static void main(String[] args) {
  3. int option = 8;
  4. String optionsString;
  5. switch (month) {
  6. case 1: optionsString = "Left";
  7. break;
  8. case 2: optionsString = "Right";
  9. break;
  10. case 3: optionsString = "Forward";
  11. break;
  12. case 4: optionsString = "Back";
  13. break;
  14. default: optionsString = "Invalid Choice";
  15. break;
  16. }
  17. System.out.println(optionsString);
  18. }
  19. }

comments powered by Disqus