Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit deb7717

Browse files
第五篇
1 parent 54d129b commit deb7717

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
如何将枚举转换成数组
2+
问题:
3+
假设我有一个枚举类是这样的:
4+
public enum Blah {
5+
A, B, C, D
6+
}
7+
我想要将枚举类的值转化成一个数组,比如"A"怎么可能是Blah.A.怎么有可能做到这点?我需要Enum.valueOf()这个方法吗?如果是这样,我应该怎么用他?
8+
9+
回答:
10+
是的,Blah.valuOf("A")将会给你Blah.A。
11+
valueOf()和values()这些静态方法是在编译时创建的,而且不会出现在源代码里。不过他们确实有出现在Javadoc,比如Dialog.ModalityType有这两个方法。
12+
stackoverflow链接:
13+
http://stackoverflow.com/questions/604424/lookup-enum-by-string-value

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /