Java½â»ó4 38²»ÊÜ»¶ÓµÄ±ö¿Í
±¾ÃÕÌâÖеijÌÐòËù½¨Ä£µÄϵͳ£¬½«³¢ÊÔ×Å´ÓÆä»·¾³ÖжÁÈ¡Ò»¸öÓû§ID£¬Èç¹ûÕâÖÖ³¢ÊÔʧ°ÜÁË£¬ÔòȱʡµØÈÏΪËüÊÇÒ»¸öÀ´±öÓû§¡£¸Ã³ÌÐòµÄ×÷Õß½«Ãæ¶ÔÓÐÒ»¸ö¾²Ì¬ÓòµÄ³õʼ»¯±í´ïʽ¿ÉÄÜ»áÅ׳öÒì³£µÄÇé¿ö¡£ÒòΪJava²»ÔÊÐí¾²Ì¬³õʼ»¯²Ù×÷Å׳ö±»¼ì²éÒì³££¬ËùÒÔ³õʼ»¯±ØÐë°ü×°ÔÚtry-finallyÓï¾ä¿éÖС£ÄÇô£¬ÏÂÃæµÄ³ÌÐò»á´òÓ¡³öʲôÄØ£¿
public class UnwelcomeGuest {
public static final long GUEST_USER_ID = -1;
private static final long USER_ID;
static {
try {
USER_ID = getUserIdfromEnvironment();
} catch (IdUnavailableException e) {
USER_ID = GUEST_USER_ID;
System.out.println("Logging in as guest");
}
}
private static long getUserIdfromEnvironment()
throws IdUnavailableException {
throw new IdUnavailableException();
}
public static void main(String[] args) {
System.out.println("User ID: " + USER_ID);
}
}
class IdUnavailableException extends Exception {
}
¸Ã³ÌÐò¿´ÆðÀ´ºÜÖ±¹Û¡£¶ÔgetUserIdfromEnvironmentµÄµ÷Óý«Å׳öÒ»¸öÒì³££¬´Ó¶øʹ³ÌÐò½«GUEST_USER_ID(-1L)¸³Öµ¸øUSER_ID£¬²¢´òÓ¡Loggin in as guest¡£È»ºómain·½·¨Ö´ÐУ¬Ê¹³ÌÐò´òÓ¡User ID: -1¡£±íÏóÔÙ´ÎÆÛÆÁËÎÒÃÇ£¬¸Ã³ÌÐò²¢²»ÄܱàÒë¡£Èç¹ûÄã³¢ÊÔ×ÅÈ¥±àÒëËü£¬Ä㽫¿´µ½ºÍÏÂÃæÄÚÈÝÀàËƵÄÒ»Ìõ´íÎóÐÅÏ¢£º
UnwelcomeGuest.java:10:
variable USER_ID might already have been assigned
USER_ID = GUEST_USER_ID;
^
ÎÊÌâ³öÔÚÄÄÀïÁË£¿USER_IDÓòÊÇÒ»¸ö¿Õfinal£¨blank final£©£¬ËüÊÇÒ»¸öÔÚÉùÃ÷ÖÐûÓнøÐгõʼ»¯²Ù×÷µÄfinalÓò[JLS 4.12.4]¡£ºÜÃ÷ÏÔ£¬Ö»ÓÐÔÚ¶ÔUSER_ID¸³ÖµÊ§°Üʱ£¬²Å»áÔÚtryÓï¾ä¿éÖÐÅ׳öÒì³££¬Òò´Ë£¬ÔÚcatchÓï¾ä¿éÖи³ÖµÊÇÏ൱°²È«µÄ¡£²»¹ÜÔõÑùÖ´Ðо²Ì¬³õʼ»¯²Ù×÷Óï¾ä¿é£¬Ö»»á¶ÔUSER_ID¸³ÖµÒ»´Î£¬ÕâÕýÊÇ¿ÕfinalËùÒªÇóµÄ¡£ÎªÊ²Ã´±àÒëÆ÷²»ÖªµÀÕâЩÄØ£¿
Ҫȷ¶¨Ò»¸ö³ÌÐòÊÇ·ñ¿ÉÒÔ²»Ö¹Ò»´ÎµØ¶ÔÒ»¸ö¿Õfinal½øÐи³ÖµÊÇÒ»¸öºÜÀ§ÄѵÄÎÊÌâ¡£ÊÂʵÉÏ£¬ÕâÊDz»¿ÉÄܵġ£ÕâµÈ¼ÛÓÚ¾µäµÄÍ£»úÎÊÌ⣬Ëüͨ³£±»ÈÏΪÊDz»¿ÉÄܽâ¾öµÄ[Turing 36]¡£ÎªÁËÄܹ»±àд³öÒ»¸ö±àÒëÆ÷£¬ÓïÑԹ淶ÔÚÕâÒ»µãÉϲÉÓÃÁ˱£Êصķ½Ê½¡£ÔÚ³ÌÐòÖУ¬Ò»¸ö¿ÕfinalÓòÖ»ÓÐÔÚËüÊÇÃ÷ȷδ¸³¹ýÖµµÄµØ·½²Å¿ÉÒÔ±»¸³Öµ¡£¹æ·¶³¤Æª´óÂ
Ïà¹ØÎĵµ£º
ÓëÃÕÌâ26ÖеijÌÐòÒ»Ñù£¬ÏÂÃæµÄ³ÌÐòÒ²°üº¬ÁËÒ»¸ö¼Ç¼ÔÚÖÕֹǰÓжàÉٴεü´úµÄÑ»·¡£ÓëÄǸö³ÌÐò²»Í¬µÄÊÇ£¬Õâ¸ö³ÌÐòʹÓõÄÊÇ×óÒƲÙ×÷·û£¨<<£©¡£ÄãµÄÈÎÎñÕÕ¾ÉÊÇÒªÖ¸³öÕâ¸ö³ÌÐò½«´òӡʲô¡£µ±ÄãÔĶÁÕâ¸ö³ÌÐòʱ£¬Çë¼Çס Java ʹÓõÄÊÇ»ùÓÚ2µÄ²¹ÂëµÄ¶þ½øÖÆËãÊõÔËË㣬Òò´Ë-1ÔÚÈκÎÓзûºÅµÄÕûÊýÀàÐÍÖУ¨byte¡¢short¡¢int»òlong£ ......
javaÓëmysqlÂÒÂëµÄÎÊÌâ
javaÓëmysqlÂÒÂëµÄÎÊÌâ
¹Ø¼ü×Ö: javaÓëmysqlÂÒÂëµÄÎÊÌâ
½â¾ö·½·¨Ò»:(×îÖØÒªµÄÒ»ÖÖ·½·¨)
Äã¿´ÏÂmy.ini£¬ÓÐÎÞ
[mysql]
default-character-set=utf8
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
È»ºó½¨Á¢±íʱ£¬Ò²ÒªÓ㨱ÈÈ磩
DROP TABLE IF ......
Ò»¡¢Ç°ÑÔ
±¾Îļٶ¨ÄãÓÐÒ»¶¨µÄJ2EE¿ª·¢¾Ñ飬Õâ¸ö½Ì³ÌûÓйý¶àµÄÉæ¼°»ù´¡ÖªÊ¶ºÍ¿ª·¢Ï¸½Ú¡£Èç¹ûÔÚÔĶÁ¹ý³Ì³öÓÐʲôÎÊÌ⣬»¹ÇëÓëÎÒÁªÏµ½»Á÷¡£
Èç¹ûʹÓÃGOOGLE¡¢BAIDUµÈËÑË÷¹¤¾ß£¬ËÑË÷WebServiceµÄÏà¹Ø֪ʶ£¬¿ÉÒԲ鵽N¶àµÄÍøÒ³£¬ÎÒ¾ÍÊÇͨ¹ýÕâЩÍøÒ³µÄѧϰ£¬Öð½¥ÕÆÎ ......
ÇëÌṩһ¸ö¶ÔiµÄÉùÃ÷£¬½«ÏÂÃæµÄÑ»·×ª±äΪһ¸öÎÞÏÞÑ»·£º
while (i <= j && j <= i && i != j) {
}
àÞ£¬²»£¬²»ÒªÔÙ¸øÎÒ¿´ÆðÀ´²»¿ÉÄܵÄÑ»·ÁË£¡Èç¹ûi <= j ²¢ÇÒ j <= i£¬i²»Êǿ϶¨µÈÓÚjÂð£¿ÕâÒ»ÊôÐÔ¶ÔʵÊý¿Ï¶¨ÓÐЧ¡£ÊÂʵÉÏ£¬ËüÊÇÈç´ËµØÖØÒª£¬ÒÔÖÁÓÚËüÓÐÕâÑùµÄ¶¨Ò壺ʵÊýÉϵÄ≤¹ØϵÊÇ·´¶Ô³ ......