Effective Java ѧϰ±Ê¼Ç£¨3£©
ÔÚʵÏÖsingletonģʽʱ£¬ÎÒÃÇÓÐÒÔϼ¸ÖÖ·½·¨¡£ 1. public static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯Êý¡£ public class Singleton{
public static final Singleton INSTANCE = new Singleton();
private Singleton() { ... }
} ÕâÖÖ·½·¨¼òµ¥£¬ÆäÖеÄ×Ö¶ÎÈÃÈËһĿÁËÈ»¾ÍÖªµÀÕâ¸öÀàÊÇSingletonģʽ£¬ÓÃfinal¹Ø¼ü×ÖÈ·±£Õâ¸ö±äÁ¿ÔÚ³õʼ»¯ºó¾Í²»»áÔÙ±»¸ü¸Ä£¬µ«Òª×¢ÒâµÄÊÇСÐÄ·ÀÖ¹ÉÙÊý±ðÓÐÓÃÐĵijÌÐòʹÓÃAccessibleObject.setAccessibleÀ´·ÃÎÊ˽Óй¹Ô캯Êý£¬Õâʱ¿ÉÒÔÔÚ˽Óй¹Ô캯ÊýÖÐÅжϵ±´´½¨µÚ¶þ¸öʵÀýµÄʱºòÅ׳öÒ»¸öÒì³£¡£ 2. private static final ×ֶμÓÉÏprivate µÄ¹¹Ô캯ÊýÔÙ¼ÓÉÏpublic ¾²Ì¬¹¤³§º¯Êý public class Singleton{
private static final Singleton INSTANCE = new Singleton();
private Singleton() { ... }
public static Singleton getInstance{}{return INSTANCE;} } ÕâÖÖ·½Ê½²»Óõ£ÐÄÐÔÄÜÎÊÌ⣬ÒòΪÏÖÔÚµÄJVM»á°Ñ¾ø´ó¶àÊýµÄ¾²Ì¬¹¤³§º¯Êý¸ÄΪÄÚÁª¡£´ËÍ⣬ÕâÖÖ·½·¨»¹¿ÉÒÔÔÚ²»¸Ä±äAPIµÄÇé¿ö϶Էµ»ØÖµ½øÐиı䣬¼´ÔÚÒÔºó¸ù¾ÝÐèÒªÊÇ·ñ·µ»ØµÚ¶þ¸öʵÀý£¬»òÊÇÿ¸öÏß³ÌÒ»¸öʵÀý¡£ ¶ÔÓÚÒÔÉÏÁ½ÖÖ·½·¨ÔÚ´®Ðл¯µÄʱºòҪעÒ⣬²»Äܽö½öÖ»¼ÓÉÏimplements Serializable½Ó¿Ú£¬ÕâÑù»áµ¼ÖÂÿ´Î·´ÐòÁл¯µÄʱºò´´½¨Ò»¸öжÔÏó£¬ÕâÑù¾Í²»ÊÇÕæÕýµÄsingletonÁË£¬½â¾öÕâ¸öÎÊÌâµÄ·½·¨ÊÇÔÚÉùÃ÷µÄʱºò¶Ôÿһ¸öfinal×ֶμÓÉÏtransient¹Ø¼ü×Ö£¬È»ºóÔÙʵÏÖÒ»¸öreadResolve·½·¨¡£ private Object readResolve() {
return INSTANCE;
} ¶ÔÓÚjava 1.5ºóµÄ°æ±¾£¬ÊµÏÖsingletonģʽ×îºÃµÄ·½·¨ÊÇÓÃö¾Ù¡£
public enum Singleton {
INSTANCE; } ÕâÖÖ·½·¨Ã»ÓÐÉÏÃæ˵µÄȱµã£¬ÊÇ×îÓŵķ½·¨¡£
Ïà¹ØÎĵµ£º
ÀûÓÃJNI¼¼Êõ£¬¿ÉÒÔ×öµ½C/C++ÓëJavaÖ®¼äµÄÏ໥µ÷Óá£
1¡¢Javaµ÷ÓÃC/C++½Ó¿Ú
Õâ¸öÊÇJNI×î»ù±¾µÄÓ¦Óã¬JNIÓкܶàÕâ·½ÃæµÄÀý×Ó´úÂë¡£Ò»°ã°ÑC/C++д³É¶¯Ì¬Á´½Ó¿â£»ÔÚJava³ÌÐòÔÚLoadLibrary£¬ÀûÓÃnative½Ó¿Ú£¬¼´¿ÉÍê³Éµ÷Óá£
2¡¢C/C++»Øµ÷Java½Ó¿Ú
ÕâÖÖÓ÷¨£¬JNIµÄÀý×ӱȽÏÉÙ¡£Æäʵ£¬Ò²±È½Ï¼òµ¥£¬JNIÒ²ÌṩÁËÕâÑùµÄ½Ó¿Ú¡ ......
1.PaginationTable.java
package com.sinoest.train.common;
import java.util.List;
/**
* ·ÖÒ³±í
* @author ÀîÒ×烜-ÐÞ¸Ä
* 2009-6-17
*/
public class PaginationTable {
private List<?> entryList;//> Êý¾Ý
private int totalNumOfRows;// ×ÜÐÐÊý
private int rowsPerPage = 10;// ......
http://www.blogjava.net/flysky19/articles/93492.html
1.java project»·¾³£¬Ê¹ÓÃjava.ioÓÃÏà¶Ô·¾¶¶ÁÈ¡ÎļþµÄÀý×Ó£º
*Ŀ¼½á¹¹£º
DecisionTree
|___src
  ......
Ò»¡¢²»±äģʽ£º
Ò»¸ö×Ö·û´®¶ÔÏó´´½¨ºóËüµÄÖµ²»Äܸı䡣
String str1="hello";//´´½¨Ò»¸ö¶ÔÏóhello£¬²»»á±ä£»
System.out.println(str1);
str1+=" world!";//Á½¸ö×Ö·û´®¶ÔÏóÕ³Õ³£¬ÏµÍ³Æäʵ´´½¨ÁËÒ»¸öеĶÔÏ󣬰ÑStr1µÄÖ¸Ïò¸ÄÁË£¬Ö¸ÏòеĶÔÏó£»hello¾Í & ......
JAVA·´Éä»úÖÆ
¸ÅÊö
¡¡¡¡ÓÐʱºòÎÒÃÇ˵ij¸öÓïÑÔ¾ßÓкÜÇ¿µÄ¶¯Ì¬ÐÔ£¬ÓÐʱºòÎÒÃÇ»áÇø·Ö¶¯Ì¬ºÍ¾²Ì¬µÄ²»Í¬¼¼ÊõÓë×÷·¨¡£ÎÒÃÇÀÊÀÊÉÏ¿Ú¶¯Ì¬°ó¶¨£¨dynamic binding£©¡¢¶¯Ì¬Á´½Ó£¨dynamic linking£©¡¢¶¯Ì¬¼ÓÔØ£¨dynamic loading£©µÈ¡£È»¶ø“¶¯Ì¬”Ò»´ÊÆäʵûÓоø¶Ô¶øÆÕ±éÊÊÓõÄÑϸñ¶¨Ò壬ÓÐʱºòÉõÖÁÏñ¶ÔÏóµ¼Ïòµ±³õ±»µ¼Èë±à³ ......