---
title: "java中调用switch函数需要注意的地方"
author: "寻梦者"
date: "2012-11-27T17:48:51Z"
tags: []
categories: ["编程语言"]
slug: "java-switch"
draft: false
lastmod: "2012-11-27T17:48:51Z"
id: 1736157
url: "https://geyubin.iteye.com/blog/1736157"
---

```
  public int  switchNum(int num){
        switch (num) {
            case 1:
                return 1;
            case 2:
            case 3:
                return 10;
            default:
                break;
        }
        
        return 0;
    }
```

   在这段语句里面看，如果传入的num = 2;

   那么返回的结果是10

 

 

   switch语句的判断条件可以接受int,byte,char,short,不能接受其他类型.