【发布时间】:2015-10-29 15:24:41
【问题描述】:
我想知道两件事:
- 从 switch 转换为 something 是否值得
- 在我的情况下会是什么样子?对我来说最大的问题是“case ID_BOTH:”
小菜一碟:
public void init( int boxID ) {
initComponentText();
switch ( boxID ) {
case ID_IMAGE:
initComponentImg();
break;
case ID_BOOL:
initComponentBool();
break;
case ID_BOTH:
initComponentBool();
initComponentImg();
break;
}
}
private void initComponentImg() {
img = new ComponentImg( switchComponent );
}
private void initComponentBool() {
bool = new ComponentBool( switchComponent );
}
private void initComponentText() {
text = new ComponentText( switchComponent );
}
感谢您的帮助和提示。
【问题讨论】:
-
在我的情况下会是什么样子?在你的情况下什么会是什么样子?
标签: java dictionary enums switch-statement