-7

I am trying to generate a random unique number for every Http request hitting my application.

How do make sure the uniqueness of such a number. Does java provide any method or API for this?

msam
  • 4,111
  • 3
  • 17
  • 32
Ankit
  • 113
  • 1
  • 7

2 Answers2

4

You could use the java.util.UUID class for that.

UUID rand = UUID.randomUUID();
System.out.println(rand);
Rahul
  • 43,125
  • 11
  • 82
  • 101
2

You could use java.util.Random - http://java.about.com/od/javautil/a/randomnumbers.htm

rvini
  • 431
  • 1
  • 4
  • 12