java switch
int day = 4;
switch (day) {
case 6:
System.out.println("Today is Saturday");
break;
case 7:
System.out.println("Today is Sunday");
break;
default:
System.out.println("Looking forward to the Weekend");
}
// Outputs "Looking forward to the Weekend"// switch statement
switch(expression)
{
// case statements
// values must be of same type of expression
case value1 :
// Statements
break; // break is optional
case value2 :
// Statements
break; // break is optional
// We can have any number of case statements
// below is default statement, used when none of the cases is true.
// No break is needed in the default case.
default :
// Statements
}
switch(x){
case(0): //if x == 0
//do some stuff
break;
//add more cases
default: //when x does not match any case
//do some stuff
break;
}
Also in Java:
- bukkit register commands
- update value of an arraylist java
- float to string java
- code to include layout from java in android
- java 8 stream option
- indexof java
- java pass array as method parameter
- java import biginteger
- android findviewbyid from item.actionView returns null
- java merge sort
- two dimensional array in java example program
- java create inputstream from string
- java enum
- .length array java
- Java array hashcode
- waht does&& mean in java
- how to count the number of occurrences of an element in a arraylist in java
- json request body not getting parsed by spring boot controller
- find the day of the week Calendar class in java
- run spring boot application command line
- android hide and show bottom navigation
- variable cannot be dereferenced java
- change button color java swing
- how to remove all components from layeredPane java