首页
论坛
图书
开发资料
在线文档
网址
下载
联系我们
 新闻│Java│JavaScript│Eclipse│Eclipse 英文│J2EE│J2ME│J2SE│JSP│Netbeans│Hibernate│JBuilder│Spring│Struts
站内搜索: 请输入搜索关键词

当前页面: 开发资料首页 → Java 专题 → java产生UUID

java产生UUID

摘要: java产生UUID

</td> </tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="283" height="86" align="center" valign="top"> </td> <td width="401" valign="top"> GUID是一个128位长的数字,一般用16进制表示。算法的核心思想是结合机器的网卡、当地时间、一个随机数来生成GUID。从理论上讲,如果一台机器每秒产生10000000个GUID,则可以保证(概率意义上)3240年不重复。

UUID是1.5中新增的一个类,在java.util下,用它可以产生一个号称全球唯一的ID
import java.util.UUID;
public class Test {
public static void main(String[] args) {
UUID uuid = UUID.randomUUID();
System.out.println (uuid);
}
}
编译运行输出:
07ca3dec-b674-41d0-af9e-9c37583b08bb

</td></tr> <tr> <td height="20" colspan="2">


考考你(28)
Given this code snippet:
try {
tryThis();
return;
} catch(IOException x1) {
System.out.println("exception 1");
return;
} catch(Exception x2) {
System.out.println("exception 2");
return;
} finally {
System.out.println("finally");
}
what will appear in the standard output if tryThis() throws a IOException?
a. "exception 1" followed by "finally"
b. "exception 2" followed by "finally"
c. "exception 1"
d. "exception 2"


点击查看答案

</td> </tr> </table>

 


</td> </tr> <tr>


↑返回目录
前一篇: 背包问题的穷举解法
后一篇: 抽象类和接口的区别

首页 | 全站 Sitemap | 联系我们 | 设为首页 | 收藏本站
版权所有 Copyright © 2006-2007, Java 编程资料牛鼻站, All rights reserved