Using javap -c classname , you can check the bytecode yourself,
Here is option 1:
(Note: I had to initialize a = null , otherwise it will not compile)
7: aconst_null 8: astore_2 9: iload_1 10: tableswitch{ //1 to 3 1: 36; 2: 42; 3: 48; default: 51 } 36: ldc
Here is option 2:
7: iload_1 8: tableswitch{ //1 to 3 1: 36; 2: 47; 3: 58; default: 66 } 36: getstatic
Personally, I do not think that the bytecode is better in this case, I consider option 1 to be more readable.
source share