Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

java switch

Name: Anonymous 2011-10-20 11:32

Why does java not allow String objects to be used in the switch/case statements? Couldn't the compile invoke hashcode() on those strings thus producing a unique integer value to represent the constant in the cases?

Name: Anonymous 2011-10-21 20:11

>>31

Good lord, what's wrong with using strcmp instead of bullshitting C?

Consider that your code is also assuming that the strings are always nullterminated, which is not a clever thing to do.

All in all, rewrite it in C++ to use std::string and make it threadsafe, and you can color me impressed.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List