elibraryportal Logo

Switch Statement in Java

Multiple condition, executes one statement that is called switch statement.

Syntax:

Switch statement in java

Example 1:

Output

Switch statementb Example in java

Example 2: Simple Check Vowel or Consonant

Output:

Vowel

Example 3: Check Vowel or Consonant by the user input

Output:

Switch Statement UserInput Example  in java

Switch Statement is Fall Through

Switch statement is fall-through. It means it executes all statements after the first match if a break statement is not present.

Example

Output

Switch Fall Example  in java

Nested Switch Statement in Java

We can use switch statement inside other switch statement in Java. It is known as nested switch statement.

Example

Output

Nested Switch Example  in java
Next TopicLoops in Java