zoukankan      html  css  js  c++  java
  • Java Switch(String)

     1 package shb.java.test;
     2 /**
     3  * switch支持字符串
     4  * @Package:shb.java.test
     5  * @Description:
     6  * @author shaobn
     7  * @Date 2015-9-9上午8:55:41
     8  */
     9 public class test_3 {
    10     public static void main(String[] args) {
    11         System.out.println(testSwitchStr("jiangsu"));
    12         System.out.println(testSwitchInt(2));
    13         System.out.println(testSwitchChar('B'));
    14     }
    15     public static char testSwitchChar(char ch){
    16         switch (ch) {
    17         case 'A':
    18             return 'A';
    19         case 'B':
    20             return 'B';
    21         default:
    22             return 'R';
    23         }
    24         
    25     }
    26     public static int testSwitchInt(int num){
    27         switch (num) {
    28         case 1:
    29             return 1;
    30         case 2:
    31             return 2;
    32         default:
    33             return 0;
    34         }
    35     }
    36     public static String testSwitchStr(String str){
    37         switch (str) {
    38         case "beijing":
    39             return "hellobeijing";
    40         case "jiangsu":
    41             return "hellojiangsu";
    42         default:
    43             return "helloworld";
    44         }
    45         
    46     }
    47 }
    吾宁做一叶扁舟,始航于湖边,遨游于海上,浪迹于江中。
  • 相关阅读:
    Java8新特性学习笔记(一) Lambda表达式
    android游戏动画特效的一些处理
    start from here
    感知机回归
    2020/2/21
    梯度下降
    凸优化
    批量归一化和残差网络
    Momentum
    词嵌入基础
  • 原文地址:https://www.cnblogs.com/assassin666/p/4793607.html
Copyright © 2011-2022 走看看