Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试为每个命中我的应用程序的 Http 请求生成一个随机的唯一编号。
如何确保这样一个数字的唯一性。java是否为此提供任何方法或API?
你可以使用这个java.util.UUID类。
java.util.UUID
UUID rand = UUID.randomUUID(); System.out.println(rand);
您可以使用 java.util.Random - http://java.about.com/od/javautil/a/randomnumbers.htm