I read in an article on Switch vs If that if we use String as switch parameter,the compiler will not make a jump table. Is this correct and if yes, pleas explain why?
Thanks
PS
I’m more interested in knowing this regarding java. And the part I read about this is from an answer here in Stackoverflow. So here’s the link stackoverflow.com/a/395965/1043937
It says about c#, but since java also has the same feature since 1.7, Can someone please explain.
Switch statements in C cannot accept strings as parameters.
Switch statements on strings in java are available since java 1.7. They weren’t before as this block was modeled from the c feature. The fact that java uses, or not, a jump table is implementation dependent and the result also depends on the values.
Edit : for details about the implementation, refer to the link provided by Jon.