How can I convert a non-numeric String to an Integer?
I got for instance:
String unique = "FUBAR";
String a = "A";
This is impossible. Think about it, an
Integer can only be 32 bits. So, by the pigeonhole principle, there must exist at least two strings that have the same
Integer value no matter what technique you use for conversion. In reality, there are infinite with the same values...
If you're just looking for an efficient mapping, then I suggest that you just use the
int returned by
hashCode(), which for reference is actually 31 bits.