How switch cases are executed for strings?

有些话、适合烂在心里 提交于 2019-12-04 19:06:34

3) I believe JDeveloper has bytecode debugger feature. If JDeveloper is not and option, check out these tools I found:

http://sourceforge.net/projects/jbcd/

http://andrei.gmxhome.de/bytecode/index.html

http://www.drgarbage.com/how-to-debug-bytecode-with-bytecode-visualizer.html

Not sure about number 3 but looking at the byte code is probably too low level to easily see what methods are being used.

1) the strings are compared using .equals().

2) the strings remain as String objects

See: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html

1 - The String in the switch expression is compared with the expressions associated with each case label as if the String.equals method were being used.

2 - Normal String object is used for this switch case statement

http://blogs.oracle.com/darcy/entry/project_coin_string_switch_anatomy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!