The Switch Statement

Switch?


Before java 1.7 the switch statement would only handled byte, char, short and int or primitive data types... but now... (as of java 7) it handles strings!

This is a great improvement since strings are used a lot in the programming world. Why did't java support it before? Because strings are not exactly primitive data types. Strings are arrays of characters... characters (char) are primitive data types.

CREATED 2020-02-13 11:15:41.0

010-00-00-62

UPDATED 2020-02-13 11:16:03.0

The Contstruct


  switch(<variable>){   case <value>:    break;   case <value>:    break;   default:    break;  }      

Don't foget the break. It will execute each block or case untill it comes up against one.

CREATED 2020-02-13 11:40:52.0

010-00-00-63

UPDATED 2020-02-13 11:41:08.0

An Example...


CREATED 2020-02-13 12:00:17.0

010-00-00-64

UPDATED 2020-02-13 12:00:35.0

Knowledge

L
I
N
K
S

DBID: db.wam

Page Server: Ithica

©2012 Leistware Data Systems

      Hello anonymous