[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Try permutation and combination of a string element appended with some Randomized generated string/number.
SCJP 1.5
In Java 1.5, static UUID UUID.fromString(String name);
SCJP 1.5
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Bharadwaj Adepu wrote:Here one more thing is the length of the generated Unique ID must be less than the original String.
Integer class doesn't have toString(java.lang.String) Method and String class doesn't have any hashcode() method.
So how should this work for the empty string? (There are no strings with length less than zero.)
SCJP 1.5
Integer.toString( myString.hashCode() );
SCJP 1.5
Bharadwaj Adepu wrote:But am not sure if this method creates a same hashCode for same string, i have tested this but not sure...
Bharadwaj Adepu wrote:
But am not sure if this method creates a same hashCode for same string, i have tested this but not sure...
http://java.sun.com/javase/6/docs/api/java/lang/Object.html#hashCode() wrote: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
http://java.sun.com/javase/6/docs/api/java/lang/Object.html#hashCode() wrote: It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results.
Bharadwaj Adepu wrote:
Try permutation and combination of a string element appended with some Randomized generated string/number.
I think this doesn't work, because, the next time when i want to generate the Unique ID for the same string then this randomized generation doesn't work as the same Unique id doesn't get generated.
Bharadwaj Adepu wrote:
Here one more thing is the length of the generated Unique ID must be less than the original String.
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Get out of my mind! Look! A tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|