In the above program, I am using enum for the operating system. The switch case needs to be performed based upon the user input. The return type of readLine() is string. How can we change the String to enum.
There is a mapping from the enum field name to the enum instance itself implicitly using the valueOf method. Quite often, you need to use something other than the field name as the key, in which case, the API Specification recommends the use of EnumMap. Being the person I am, I recognise that this approach is somewhat flawed, so I suggest using a Map, perhaps lazily loaded (within a static nested class of the enum type). At least, this is what I do.
That is true, you do have everything you need with the possible exception, npi, that Color.valueOf("seafoam") would throw an IllegalArgumentException should somebody have the audacity to create a Color enumeration without it. With a map you don't get shot just for asking. Then again you have to pack that map with you so the built-in is far better on balance.