I have an 18 Character String that I need to convert into a unique long (in Java). A sample String would be: AAA2aNAAAAAAADnAAA
My String is actually an Oracle ROWID, so it can be broken down if needs be, see: http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#CNCPT713
The long number generated, (1) Must be unique, as no two results can point to the same database row and (2) Must be reversible, so I can get the ROWID String back from the long?
Any suggestions on an algorithm to use would be welcome.
Oracle forum question on this from a few years ago : http://forums.oracle.com/forums/thread.jspa?messageID=1059740
Ro
We can convert char to String in java using String. valueOf(char) method of String class and Character. toString(char) method of Character class.
A Java String contains an immutable sequence of Unicode characters. Unlike C/C++, where string is simply an array of char , A Java String is an object of the class java. lang.
A String is said to be 'Unique' if none of the letters present in the string are repeated. Write a program to accept a string and check whether the string is Unique or not.
You can't, with those requirements.
18 characters of (assuming) upper and lower case letters has 5618 or about 2.93348915 × 10331 combinations. This is (way) more than the approximate 1.84467441 × 1019 combinations available among 64 bits.
UPDATE: I had the combinatorics wrong, heh. Same result though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With