1.基本switch语句
switch一般用来做多个值的判断,表示区间的时候用if,else,而表示值并且有较多值的时候我们可以使用switch语句。
1.1代码演示
package basic;
/**
* This is the fifth code. Names and comments should follow my style strictly.
*
* @author Wu Jun 2298320301@qq.com.com.
*/
public class Day5 {
/**
*********************
* The entrance of the program.
*
* @param args Not used now.
*********************
*/
public static void main(String args[]) {
scoreToLevelTest();
}// Of main
/**
*********************
* Score to level.
*
* @param paraScore From 0 to 100.
* @return The level from A to F.
*********************
*/
public static char scoreToLevel(int paraScore) {
// E stands for error, and F stands for fail.
char resultLevel = 'E';
// Divide by 10, the result ranges from 0 to 10
int tempDigitalLevel = paraScore / 10;
// The use of break is important.
switch (tempDigit