I have the following method to create random ids that look like positive long numbers (I can't use UUID.randomUUID().toString()
for non-technical reasons that are outside the scope of this question):
public String createRandomId() {
UUID uuid = UUID.randomUUID();
return String.valueOf(uuid.getMostSignificantBits() & Long.MAX_VALUE) +
(uuid.getLeastSignificantBits() & Long.MAX_VALUE);
}
The question is simple: would this method yield a unique result? (I mean, unique like in UUID.randomUUID()
)