Java Switch(String)
2015-09-09 08:56
465 查看
package shb.java.test; /** * switch支持字符串 * @Package:shb.java.test * @Description: * @author shaobn * @Date 2015-9-9上午8:55:41 */ public class test_3 { public static void main(String[] args) { System.out.println(testSwitchStr("jiangsu")); System.out.println(testSwitchInt(2)); System.out.println(testSwitchChar('B')); } public static char testSwitchChar(char ch){ switch (ch) { case 'A': return 'A'; case 'B': return 'B'; default: return 'R'; } } public static int testSwitchInt(int num){ switch (num) { case 1: return 1; case 2: return 2; default: return 0; } } public static String testSwitchStr(String str){ switch (str) { case "beijing": return "hellobeijing"; case "jiangsu": return "hellojiangsu"; default: return "helloworld"; } } }
相关文章推荐
- 为什么JAVA只允许单继承
- javaweb -- 获取请求IP(附实现源码)
- Eclipse中jsp、js文件编辑时,卡死现象解决汇总
- Spring aop学习详解
- JAVA高并发学习笔记(四) 无锁
- java 工厂的变形模拟的各种应用
- struts2值传递方法
- spring配置详解
- struts.xml
- 平时常用的一些java方法,请留意
- java简单的计算器类
- eclipse快捷键以及使用技巧大全
- java自带线程池和队列详细讲解
- How to use Session attributes in Spring-mvc
- Get Session in Spring AOP
- Struts2中action获取request、response、session的方式
- 【小熊刷题】Binary Tree Right Side View <Leetcode 199, Java>
- Java 反射,通过反射调用所有的方法,包括private方法
- 《Java核心技术卷一》笔记 多线程
- 【Java】增强的for流程