java²úÉúËæ»úÊýµÄ¼¸ÖÖ·½Ê½
Ò».ÔÚj2seÀïÎÒÃÇ¿ÉÒÔʹÓÃMath.random()·½·¨À´²úÉúÒ»¸öËæ»úÊý£¬Õâ¸ö²úÉúµÄËæ»úÊýÊÇ0-1Ö®¼äµÄÒ»¸ödouble£¬ÎÒÃÇ¿ÉÒÔ°ÑËû³ËÒÔÒ»¶¨µÄÊý£¬±ÈÈç˵³ËÒÔ100£¬Ëû¾ÍÊǸö100ÒÔÄÚµÄËæ»ú£¬Õâ¸öÔÚj2meÖÐûÓС£
¶þ.ÔÚjava.utilÕâ¸ö°üÀïÃæÌṩÁËÒ»¸öRandomµÄÀ࣬ÎÒÃÇ¿ÉÒÔн¨Ò»¸öRandomµÄ¶ÔÏóÀ´²úÉúËæ»úÊý£¬Ëû¿ÉÒÔ²úÉúËæ»úÕûÊý¡¢Ëæ»úfloat¡¢Ëæ»údouble£¬Ëæ»úlong£¬Õâ¸öÒ²ÊÇÎÒÃÇÔÚj2meµÄ³ÌÐòÀï¾³£ÓõÄÒ»¸öÈ¡Ëæ»úÊýµÄ·½·¨¡£
Èý.ÔÚÎÒÃǵÄSystemÀàÖÐÓÐÒ»¸öcurrentTimeMillis()·½·¨£¬Õâ¸ö·½·¨·µ»ØÒ»¸ö´Ó1970Äê1ÔÂ1ºÅ0µã0·Ö0Ã뵽ĿǰµÄÒ»¸öºÁÃëÊý£¬·µ»ØÀàÐÍÊÇlong£¬ÎÒÃÇ¿ÉÒÔÄÃËû×÷Ϊһ¸öËæ»úÊý£¬ÎÒÃÇ¿ÉÒÔÄÃËû¶ÔһЩÊýÈ¡Ä££¬¾Í¿ÉÒÔ°ÑËûÏÞÖÆÔÚÒ»¸ö·¶Î§Ö®ÄÚÀ²
ÆäʵÔÚRandomµÄĬÈϹ¹Ôì·½·¨ÀïÒ²ÊÇʹÓÃÉÏÃæµÚÈýÖÖ·½·¨½øÐÐËæ»úÊýµÄ²úÉúµÄ
¶ÔÓÚ·½·¨¶þÖеÄRandomÀàÓÐÒÔÏÂ˵Ã÷£º
java.util.RandomÀàÓÐÁ½ÖÖ·½Ê½¹¹½¨·½Ê½£º´øÖÖ×ӺͲ»´øÖÖ×Ó
²»´øÖÖ×Ó£º
´ËÖÖ·½Ê½½«»á·µ»ØËæ»úµÄÊý×Ö£¬Ã¿´ÎÔËÐнá¹û²»Ò»Ñù
public class RandomTest {
public static void main(String[] args) {
java.util.Random r=new java.util.Random();
for(int i=0;i<10;i++){
System.out.println(r.nextInt());
}
}
´øÖÖ×Ó£º
´ËÖÖ·½Ê½£¬ÎÞÂÛ³ÌÐòÔËÐжàÉٴΣ¬·µ»Ø½á¹û¶¼ÊÇÒ»ÑùµÄ
public static void main(String[] args) {
java.util.Random r=new java.util.Random(10);
for(int i=0;i<10;i++){
System.out.println(r.nextInt());
}
}
Á½ÖÖ·½Ê½µÄ²î±ðÔÚÓÚ
(1) Ê×ÏÈÇë´ò¿ªJava Doc£¬ÎÒÃǻῴµ½RandomÀàµÄ˵Ã÷£º
´ËÀàµÄʵÀýÓÃÓÚÉú³ÉαËæ»úÊýÁ÷£¬´ËÀàʹÓà 48 λµÄÖÖ×Ó£¬¸ÃÖÖ×Ó¿ÉÒÔʹÓÃÏßÐÔͬÓ๫ʽ¶ÔÆä½øÐÐÐ޸ģ¨Çë²ÎÔÄ Donald Knuth µÄ¡¶The Art of Computer Programming, Volume 2¡·£¬µÚ 3.2.1 ½Ú£©¡£
Èç¹ûÓÃÏàͬµÄÖÖ×Ó´´½¨Á½¸ö Random ʵÀý£¬Ôò¶Ôÿ¸öʵÀý½øÐÐÏàͬµÄ·½·¨µ÷ÓÃÐòÁУ¬ËüÃǽ«Éú³É²¢·µ»ØÏàͬµÄÊý×ÖÐòÁС£ÎªÁ˱£Ö¤ÊµÏÖÕâÖÖÌØÐÔ£¬ÎÒÃÇΪÀàRandomÖ¸¶¨ÁËÌض¨µÄËã·¨¡£ÎªÁË Java ´úÂëµÄÍêÈ«¿ÉÒÆÖ²ÐÔ£¬Java ʵÏÖ±ØÐëÈÃÀà Random ʹÓô˴¦ËùʾµÄËùÓÐËã·¨¡£µ«ÊÇÔÊÐí Random ÀàµÄ×ÓÀàʹÓÃÆäËûËã·¨£¬Ö»ÒªÆä·ûºÏËùÓз½·¨µÄ³£¹æж¨¼´¿É¡£
Java Doc¶ÔRandomÀàÒѾ½âÊ͵÷dz£Ã÷°×£¬ÎÒÃǵIJâÊÔÒ²ÑéÖ¤ÁËÕâÒ»µã¡£
(2) Èç¹ûûÓÐÌṩÖÖ×ÓÊý£¬RandomʵÀýµÄÖÖ×ÓÊý½«Êǵ±Ç°Ê±¼äµÄºÁÃëÊý£¬¿ÉÒÔͨ¹ýSystem.currentTimeMillis()À´»ñµÃµ±Ç°Ê±¼äµÄºÁÃëÊý¡£´ò¿ªJDKµÄÔ´´úÂ룬ÎÒÃÇ¿ÉÒԷdz£Ã÷È·µØ¿´µ
Ïà¹ØÎĵµ£º
×î½üдÔ˼۵Äϵͳ,дµÃºÃÀÛ°¡,²»¹ý²î²»¶à½Ó½üÍê³ÉÁË.µ«±àÂëµÄÎÊÌâÒ»Ö±¶¼ÊÇËƶ®·Ç¶®µÄ.
Ö»ºÃÒ»µãµãÈ¥ËÑË÷javaºÍhtmlµÄ±àÂëÎÊÌâ.ºÃ·³,µ½×îºó,ÎÊÌâÊǽâ¾öÁË,µ«²»ÊÇ×îÍêÕûµÄ´¦Àí·½·¨.Ï£ÍûÒÔºó¿ÉÒÔ´¦ÀíºÃ.
ÔÚÒ»¸östruts2µÄ·µ»ØÌáʾµÄ×Ö·û´®µ½Ò³ÃæÖÐ.ÎÊÌâ¾ÍÊdzöÔÚÕâ×Ö·û´®ÖÐÓÐÍøÒ³µÄ»»Ð ......
ҪʹÓÃdom4j¶ÁдXMLÎĵµ,ÐèÒªÏÈÏÂÔØdom4j°ü,dom4j¹Ù·½ÍøÕ¾ÔÚ http://www.dom4j.org/
Ä¿Ç°×îÐÂdom4j°üÏÂÔصØÖ·: http://nchc.dl.sourceforge.net/sourceforge/dom4j/dom4j-1.6.1.zip
½â¿ªºóÓÐÁ½¸ö°ü,½ö²Ù×÷XMLÎĵµµÄ»°°Ñdom4j-1.6.1.jar¼ÓÈ빤³Ì¾Í¿ÉÒÔÁË,Èç¹ûÐèҪʹÓÃXPathµÄ»°»¹ÐèÒª¼ÓÈë°üjaxen-1.1-beta-7.jar.
ÒÔÏÂ ......
Ò»¡¢new
¡¡¡¡Ê¹ÓÃjavaµÄ¹Ø¼ü×ÖnewÀ´´´½¨¶ÔÏóʵÀý¡£¹¹Ô캯ÊýÁ´ÖеÄËùÓй¹Ô캯Êý¶¼»á±»×Ô¶¯µ÷Óá£
Java´úÂ룺
¡¡¡¡ CreateInstance instance = new CreateInstance ();
¶þ¡¢clone
¹¹Ô캯Êý²»±»×Ô¶¯µ÷Óá£
¡¡¡¡Java´úÂ룺
......
public class TestClass{
public static void main(String args[]){
VarArgs(1, "one");
VarArgs(2, "one", "two");
VarArgs(3, "one", "two", "three");
VarArgs(0); // Attention!
}
static void VarArgs(int nRequired, String... trailing){
System.out.print("Required: " + nRequired + " ");
......
µÚÒ»ÕÂ ÒýÑÔ
(By wind5shy£ºhttp://blog.csdn.net/wind5shy)
µÚ¶þÕ ´´½¨ºÍÏú»Ù¶ÔÏó
(By wind5shy£ºhttp://blog.csdn.net/wind5shy)
µÚ1Ìõ£º¿¼ÂÇÓþ²Ì¬¹¤³§·½·¨´úÌæ¹¹Ô캯Êý
ºÃ´¦£º
¾²Ì¬¹¤³§·½·¨ÓÐÃû×Ö£¬±í´ï¸üÇå³þ¡£
²»Ðè´´½¨ÐµĶÔÏó¡£
¿ÉÒÔ·µ»ØÔ·µ»ØÀàÐ͵Ä×ÓÀàÐͶÔÏó¡£Ó¦Óãº1.·µ»ØÀàÐͶ¨ÒåΪ½ ......