Sorry if you felt the post was negative. If you're here to learn something, I hope you learned something from it, such as a little taste of how a switch works and why this sort of thing simply can't work, considering what a switch actually is. To the compiler, it's not just shorthand for if()...else if()...eise if() even though that's what it looks like from this side.
So the theory behind the code is simply wrong, and if you'd tried it you would have found that it can't be made to work. That's why I said, please try your code before you post it if you're not sure. Actually, it'd be best to try it even if you are sure, but that's another thing.
Specifically, what this code tries to do, which can't be done, is to use a function call as the case of a switch.
I'm being very strong on this point because there are a lot of novice Java programmers reading this, and your post is likely to confuse some of them.
Does this mean you can never see a situation where this would be useful? How would you handle the OP's situation? How would you handle other situations that at first glance may look like a switch on strings would be useful?
The original poster didn't describe a situation, they just said they wanted "to use a switch statement on String". To me, this sounds a lot like "I want to hammer a nail with a flounder". Now, I can think of a few reasons why someone might think they needed to do that (String into switch, not nail/flounder). Mostly, those involve handling user input. But I can't think of any where the switch is the best solution. If you have a particular case where you think something like this is required, I'd be happy to figure out the best solution for that case, but I can't think of anything where the best solution involves torking a String until it fits into a switch.