码迷,mamicode.com
首页 > Windows程序 > 详细

测试代码发布到博客效果(Windows Live Writer发布)

时间:2016-05-30 07:37:45      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

测试代码发布到博客效果(Windows Live Writer发布)
public class SwitchCase {

    /**

     * 1、switch后面的表达式为常量表达式,类型只能是可以转化为int、enum(1.6+)、String(1.7+)的类型

     * 2、可以转化为int类型的数据类型有:byte、short、int、char

     * 3、boolean类型的数据类型推荐用if else,java中不支持使用

     *

     *

     */

    public static int getAge(String name) {

        int age = 0;

        switch (name) {

        case "张三":

            age = 30;

            break;

        case "李四":

            age = 40;

            break;

        default:

            age = -1;

            break;

        }

        return age;

    }

 

 

    public static void main(String[] args) {

        int age = getAge("张三");

        System.out.println(age);

    }

}

测试代码发布到博客效果(Windows Live Writer发布)

标签:

原文地址:http://www.cnblogs.com/cupOf/p/5541028.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!