October 2017
Beginner
318 pages
7h 26m
English
When we want to execute different lines or blocks of code depending on the value of an individual variable, the switch statement is extremely effective. Now let's rewrite our series of if blocks using a switch statement instead. The syntax is explained in the following steps:
package switcher;
public class Switcher {
public static void main(String[] args) {
int x=1;
switch(x)
{
}
}
}
Then, just like using an if
Read now
Unlock full access