Skip to content

Commit a3cc5a6

Browse files
committed
docs: Update Java SE switch statement documentation
Added information about Java 7 string support and Java 21 switch statement enhancements, including support for long, any object type, and when clauses.
1 parent 5e8a76e commit a3cc5a6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/src/sidebar/sanfene/javase.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ Java 5 以前 `switch(expr)` 中,expr 只能是 byte、short、char、int。
305305

306306
从 Java 5 开始,Java 中引入了枚举类型, expr 也可以是 enum 类型。
307307

308-
从 Java 7 开始,expr 还可以是字符串,但是长整型在目前所有的版本中都是不可以的。
308+
从 Java 7 开始,expr 还可以是字符串。
309+
310+
从 Java 21 开始,switch 语句迎来了根本性的变革,不仅可以处理 long 类型,也能处理包括 null 在内的任意对象类型,并可通过 when 子句添加复杂的判断条件。
309311

310312
### 12.break,continue,return 的区别及作用?
311313

0 commit comments

Comments
 (0)