Java Switch Statement Part_19 |EduTech|



Java switch

The Java swap announcement executes one declaration from a couple of conditions. It is like if-else-if ladder statement. The swap announcement works with byte, short, int, long, enum types, String and some wrapper sorts like Byte, Short, Int, and Long. Since Java 7, you can use strings in the change statement.

Java Switch Statements

The swap expression is evaluated once.
The price of the expression is in contrast with the values of every case .
If there is a match, the related block of code is executed.
The destroy and default key phrases are optional, and will be described later in this chapter.

Rules for swap statement:

An expression ought to constantly execute to a result.
Case labels need to be constants and unique.
Case labels need to stop with a colon ( : ).
A damage key-word have to be current in every case.
There can be solely one default label.
We can nest a couple of swap statements.

Post a Comment

Thanks for touching with us.

Copyright © EduTech. Designed by | WebMyDesign
Edutech