Without beeing familiar with the hotspot-compiler, I can't imagine it will resort your first example.
And the hotspot optimization varies from release to release, so we can't give a final answer.
If you use an anonymous block, you reduce the visibility of obj1 to the bare minimum and avoid the (cheap) execution of 100 if-statements.
Note: please use code-tags as described here:
http://www.javaranch.com [ May 31, 2006: Message edited by: Stefan Wagner ]