Java introduced switch case with Strings in its Java7. I was wondering if using such switch case will create garbage.
For example in my program,
String s = getString();
switch(s)
{
case ABC: // ABC is a final static constant
...
case CDE: // CDE is also final static constant.
...
}
How java performs this switch case. Assume there are 10's of these switch cases. Will it create a new string everytime it is matching the string s with the case ABC and so on ?
If this is the case, it is very garbagy, so when I give switch case with 100 cases, then everytime 100 strings are going to be created.