Java½â»ó2 23²»ÀÍÎÞ»ñ
ÏÂÃæµÄ³ÌÐò½«´òÓ¡Ò»¸öµ¥´Ê£¬ÆäµÚÒ»¸ö×ÖĸÊÇÓÉÒ»¸öËæ»úÊýÉú³ÉÆ÷À´Ñ¡ÔñµÄ¡£ÇëÃèÊö¸Ã³ÌÐòµÄÐÐΪ£º
import java.util.Random;
public class Rhymes {
private static Random rnd = new Random();
public static void main(String[] args) {
StringBuffer word = null;
switch(rnd.nextInt(2)) {
case 1: word = new StringBuffer('P');
case 2: word = new StringBuffer('G');
default: word = new StringBuffer('M');
}
word.append('a');
word.append('i');
word.append('n');
System.out.println(word);
}
}
Õ§Ò»¿´£¬Õâ¸ö³ÌÐò¿ÉÄÜ»áÔÚÒ»´ÎÓÖÒ»´ÎµÄÔËÐÐÖУ¬ÒÔÏàµÈµÄ¸ÅÂÊ´òÓ¡³öPain£¬Gain»ò Main¡£¿´ÆðÀ´¸Ã³ÌÐò»á¸ù¾ÝËæ»úÊýÉú³ÉÆ÷ËùÑ¡È¡µÄÖµÀ´Ñ¡Ôñµ¥´ÊµÄµÚÒ»¸ö×Öĸ£º0Ñ¡M£¬1Ñ¡P£¬2Ñ¡G¡£ÃÕÌâµÄÌâÄ¿Ò²ÐíÒѾ¸øÄãÌṩÁËÏßË÷£¬Ëüʵ¼ÊÉϼȲ»»á´òÓ¡Pain£¬Ò²²»»á´òÓ¡Gain¡£Ò²Ðí¸üÁîÈ˳ԾªµÄÊÇ£¬ËüÒ²²»»á´òÓ¡Main£¬²¢ÇÒËüµÄÐÐΪ²»»áÔÚÒ»´ÎÓÖÒ»´ÎµÄÔËÐÐÖз¢Éú±ä»¯£¬Ëü×ÜÊÇÔÚ´òÓ¡ain¡£
ÓÐÈý¸öbug´Õµ½Ò»ÆðÒý·¢ÁËÕâÖÖÐÐΪ¡£ÄãÍêȫûÓз¢ÏÖËüÃÇÂ𣿵ÚÒ»¸öbugÊÇËùÑ¡È¡µÄËæ»úÊýʹµÃswitchÓï¾äÖ»Äܵ½´ïÆäÈýÖÖÇé¿öÖеÄÁ½ÖÖ¡£Random.nextInt(int)µÄ¹æ·¶ÃèÊöµÀ£º“·µ»ØÒ»¸öαËæ»úµÄ¡¢¾ùµÈµØ·Ö²¼ÔÚ´Ó0£¨°üÀ¨£©µ½Ö¸¶¨µÄÊýÖµ£¨²»°üÀ¨£©Ö®¼äµÄÒ»¸öintÊýÖµ”[Java-API]¡£ÕâÒâζ×űí´ïʽrnd.nextInt(2)¿ÉÄܵÄÈ¡ÖµÖ»ÓÐ0ºÍ1£¬SwitchÓï¾ä½«ÓÀÔ¶Ò²µ½²»ÁËcase 2·ÖÖ§£¬Õâ±íʾ³ÌÐò½«ÓÀÔ¶²»»á´òÓ¡Gain¡£nextIntµÄ²ÎÊýÓ¦¸ÃÊÇ3¶ø²»ÊÇ2¡£
ÕâÊÇÒ»¸öÏ൱³£¼ûµÄÎÊÌâÔ´£¬±»Êì֪Ϊ“Õ¤À¸Öù´íÎó£¨fencepost error£©”¡£Õâ¸öÃû×ÖÀ´Ô´ÓÚ¶ÔÏÂÃæÕâ¸öÎÊÌâ×î³£¼ûµÄµ«È´ÊÇ´íÎóµÄ´ð°¸£¬Èç¹ûÄãÒª½¨ÔìÒ»¸ö100Ó¢³ß³¤µÄÕ¤À¸£¬ÆäÕ¤À¸Öù¼ä¸ôΪ10Ó¢³ß£¬ÄÇôÄãÐèÒª¶àÉÙ¸ùÕ¤À¸ÖùÄØ£¿11¸ù»ò9¸ù¶¼ÊÇÕýÈ·´ð°¸£¬ÕâÈ¡¾öÓÚÊÇ·ñÒªÔÚÕ¤À¸µÄÁ½¶ËÊ÷Á¢Õ¤À¸Öù£¬µ«ÊÇ10¸ùÈ´ÊÇ´íÎóµÄ¡£Òªµ±ÐÄÕ¤À¸Öù´íÎó£¬Ã¿µ±ÄãÔÚ´¦Àí³¤¶È¡¢·¶Î§»òÄ£ÊýµÄʱºò£¬¶¼Òª×Ðϸȷ¶¨Æä¶ËµãÊÇ·ñÓ¦¸Ã±»°üÀ¨ÔÚÄÚ£¬²¢ÇÒҪȷ±£ÄãµÄ´úÂëµÄÐÐΪҪÓëÆäÏà¶ÔÓ¦¡£
µÚ¶þ¸öbugÊÇÔÚ²»Í¬µÄÇé¿ö£¨case£©ÖÐûÓÐÈκÎbreakÓï¾ä¡£²»ÂÛswitch±í´ïʽΪºÎÖµ£¬¸Ã³ÌÐò¶¼½«Ö´ÐÐÆäÏà¶ÔÓ¦µÄcaseÒÔ¼°ËùÓкóÐøµÄcase[JLS 14.11]¡£Òò´Ë£¬¾¡¹Üÿһ¸öcase¶¼¶Ô±äÁ¿word¸³ÁËÒ»¸öÖµ£¬µ«ÊÇ×ÜÊÇ×îºóÒ»¸ö¸³ÖµÊ¤³ö£¬¸²¸ÇÁËÇ°ÃæµÄ¸³Öµ¡£×îºóÒ»¸ö¸³Öµ½«×ÜÊÇ×îºóÒ»ÖÖÇé¿
Ïà¹ØÎĵµ£º
Ôڳɹ¦ÊµÏÖJavaµ÷ÓÃC++Ö®ºó£¬½ÓÏÂÀ´Ïëµ½ÄÜ·ñͨ¹ýJNAʵÏÖJavaµ÷ÓÃFortran£¬½ñÌìÊÔÑéÁËһϣ¬»¹ÊDZȽÏÈÝÒ׵ġ£
ÍøÉÏÓÐÒ»¸öJavaµ÷ÓÃF95µÄÀý×Ó£¬µ«ÊÇÎÒ¿¼ÂDz»½öҪʵÏÖF95µÄµ÷Ó㬻¹ÒªÊµÏÖF77µÄµ÷Óã¬ËùÒÔ·ÑÁËһЩÖÜÕÛ¡£
ÎÊÌâµÄ¹Ø¼üÔÚÓÚF77Ϊ¹ý³ÌÃû×Ô¶¯Ìí¼ÓÁËÒ»¸öβ²¿µÄÏ»®Ïߣ¬ËùÒÔsub1Õâ¸ö¹ý³Ì£¬µ½JavaÒ»¶Ë£¬¾Í±ä³ÉÁËsub1_£¬ ......
2008 Äê 6 ÔÂ 24 ÈÕ
ÔÎĵØÖ·£º http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0806wangys/
±¾ÎĽéÉÜ IBM FileNet P8 4.0 Platform ÌṩµÄ Content Java API¡£Ê×ÏÈ¶Ô FileNet P8 Content Engine ºÍ API ½øÐиÅÒª½éÉÜ, ²¢ËµÃ÷ÁËһЩ»ù±¾¸ÅÄËæºóÏêϸ½éÉÜÁË FileNet Content EngineÌṩµÄ»ùÓÚ EJB ......
ÓÃspyºÍmemcached for javaÁ½ÖÖ·½Ê½¶Ômemcache½øÐвÙ×÷
Ò»¡¢spy
package com.test.memcache;
import java.net.InetSocketAddress;
import java.util.concurrent.Future;
import net.spy.memcached.MemcachedClient;
/**
* ±¾ÀàÓõİüÊÇmemcached-2.4.1.jar
* ÏÂÔصØÖ·£º http://code.googl ......
javaÖо²Ì¬±äÁ¿ºÍ¾²Ì¬·½·¨·Ö±ðÓÐʲôÌص㣿
ÐüÉÍ·Ö£º0 - ½â¾öʱ¼ä£º2006-4-10 10:28
ÌáÎÊÕߣº vv_clear - ¶þ¼¶
×î¼Ñ´ð°¸
ΪʲôÎÊÁËÁ½´Î£¿ÔÙÌùÉÏÁíһƪ
Thinking:JavaÖÐstaticÓ÷¨- -
Tag£º Thinking:JavaÖÐs
Ò»¡¢static
ÇëÏÈ¿´ÏÂÃæÕâ¶Î³ÌÐò£º
public class ......
......