Tutorial :Is there a template or something for generating a switch statement for Java enum in Eclipse?



Question:

Is there a template or something for generating a switch statement for Java enum in Eclipse?

So that when I got an enum and I want to have a switch with all the values, I didn't have to write all it myself?


Solution:1

There certainly is, at least in 3.5.

Starting with something like this:

switch(a.getType()){    }  

All you need to do is click on the switch keyword and hit CTRL+1. You should get a drop down which includes the option "Add missing case statements"


Solution:2

The content assists in Eclipse 3.4 will help you write the code. Just type case and press Ctrl+Space and you'll get a list of unused enums.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »