Javaµ¥Àýģʽ
×÷Ϊ¶ÔÏóµÄ´´½¨Ä£Ê½,µ¥Àýģʽȷ±£Ä³¸öÀàÖ»ÓÐÒ»¸öʵÀý£¬¶øÇÒ×ÔÐÐʵÀý»¯²¢ÏòÕû¸öϵͳÌṩÕâ¸öʵÀý¡£Õâ¸öÀà³ÆΪµ¥ÀýÀà¡£Óɶ¨Òå¿ÉÒÔ×ܽá³öµ¥ÀýģʽµÄÒªµãÓÐÈý¸ö£ºÒ»Êǵ¥ÀýÀàÖ»ÄÜÓÐÒ»¸öʵÀý£»¶þÊÇËü±ØÐë×ÔÐд´½¨Õâ¸öʵÀý£»ÈýÊÇËü±ØÐë×ÔÐÐÏòÕû¸öϵͳÌṩÕâ¸öʵÀý¡£
ÔÚ¼ÆËã»úϵͳÖУ¬Ï̳߳ء¢»º´æ¡¢ÈÕÖ¾¶ÔÏ󡢶Ի°¿ò¡¢´òÓ¡»ú¡¢ÏÔ¿¨µÄÇý¶¯³ÌÐò¶ÔÏó³£±»Éè¼Æ³Éµ¥Àý¡£ÕâЩӦÓö¼»ò¶à»òÉÙ¾ßÓÐ×ÊÔ´¹ÜÀíÆ÷µÄ¹¦ÄÜ¡£Ã¿Ì¨¼ÆËã»ú¿ÉÒÔÓÐÈô¸É¸ö´òÓ¡»ú£¬µ«Ö»ÄÜÓÐÒ»¸öPrinter Spooler£¬ÒÔ±ÜÃâÁ½¸ö´òÓ¡×÷ҵͬʱÊä³öµ½´òÓ¡»úÖС£Ã¿Ì¨¼ÆËã»ú¿ÉÒÔÓÐÈô¸ÉͨÐŶ˿ڣ¬ÏµÍ³Ó¦µ±¼¯ÖйÜÀíÕâЩͨÐŶ˿ڣ¬ÒÔ±ÜÃâÒ»¸öͨÐŶ˿Úͬʱ±»Á½¸öÇëÇóͬʱµ÷Óá£×ÜÖ®£¬Ñ¡Ôñµ¥Àýģʽ¾ÍÊÇΪÁ˱ÜÃâ²»Ò»ÖÂ״̬£¬±ÜÃâÕþ³ö¶àÍ·¡£
Ê×ÏÈ¿´Ò»¸ö¾µäµÄµ¥ÀýʵÏÖ¡£
public class Singleton {
private static Singleton uniqueInstance = null;
private Singleton() {
// Exists only to defeat instantiation.
}
public static Singleton getInstance() {
if (uniqueInstance == null) {
uniqueInstance = new Singleton();
}
return uniqueInstance;
}
// Other methods...
}
Singletonͨ¹ý½«¹¹Ôì·½·¨ÏÞ¶¨Îªprivate±ÜÃâÁËÀàÔÚÍⲿ±»ÊµÀý»¯£¬ÔÚͬһ¸öÐéÄâ»ú·¶Î§ÄÚ£¬SingletonµÄΨһʵÀýÖ»ÄÜͨ¹ýgetInstance()·½·¨·ÃÎÊ¡££¨ÊÂʵÉÏ£¬Í¨¹ýJava·´Éä»úÖÆÊÇÄܹ»ÊµÀý»¯¹¹Ôì·½·¨ÎªprivateµÄÀàµÄ£¬ÄÇ»ù±¾ÉÏ»áʹËùÓеÄJavaµ¥ÀýʵÏÖʧЧ¡£´ËÎÊÌâÔÚ´Ë´¦²»×öÌÖÂÛ£¬¹ÃÇÒÑÚ¶úµÁÁåµØÈÏΪ·´Éä»úÖƲ»´æÔÚ¡££©
µ«ÊÇÒÔÉÏʵÏÖûÓп¼ÂÇḬ̈߳²È«ÎÊÌâ¡£ËùνḬ̈߳²È«ÊÇÖ¸£ºÈç¹ûÄãµÄ´úÂëËùÔڵĽø³ÌÖÐÓжà¸öÏß³ÌÔÚͬʱÔËÐУ¬¶øÕâЩÏ߳̿ÉÄÜ»áͬʱÔËÐÐÕâ¶Î´úÂë¡£Èç¹ûÿ´ÎÔËÐнá¹ûºÍµ¥Ïß³ÌÔËÐеĽá¹ûÊÇÒ»ÑùµÄ£¬¶øÇÒÆäËûµÄ±äÁ¿µÄÖµÒ²ºÍÔ¤ÆÚµÄÊÇÒ»ÑùµÄ£¬¾ÍÊÇḬ̈߳²È«µÄ¡£»òÕß˵£ºÒ»¸öÀà»òÕß³ÌÐòËùÌṩµÄ½Ó¿Ú¶ÔÓÚÏß³ÌÀ´ËµÊÇÔ×Ó²Ù×÷»òÕ߶à¸öÏß³ÌÖ®¼äµÄÇл»²»»áµ¼Ö¸ýӿڵÄÖ´Ðнá¹û´æÔÚ¶þÒåÐÔ,Ò²¾ÍÊÇ˵ÎÒÃDz»Óÿ¼ÂÇͬ²½µÄÎÊÌâ¡£ÏÔÈ»ÒÔÉÏʵ
Ïà¹ØÎĵµ£º
ÒÆλÔËËã·û¾ÍÊÇÔÚ¶þ½øÖƵĻù´¡É϶ÔÊý×Ö½øÐÐƽÒÆ¡£°´ÕÕƽÒƵķ½ÏòºÍÌî³äÊý×ֵĹæÔò·ÖΪÈýÖÖ£º<<£¨×óÒÆ£©¡¢>>£¨´ø·ûºÅÓÒÒÆ£©ºÍ>>>£¨ÎÞ·ûºÅÓÒÒÆ£©¡£
¡¡¡¡ÔÚÒÆλÔËËãʱ£¬byte¡¢shortºÍcharÀàÐÍÒÆλºóµÄ½á¹û»á±ä³ÉintÀàÐÍ£¬¶ÔÓÚbyte¡¢short¡¢charºÍint½øÐÐÒÆλʱ£¬¹æ¶¨Êµ¼ÊÒƶ¯µ ......
package cn.test;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
/**
* Java Reflection Cookbook
*
* @author Michael Lee
* @since 2006-8-23
* ......
platform ['plætfɔ:m] n.ƽ̨
standard edition±ê×¼°æ
enterprise ['entəpraiz] n. ÆóÒµ
bytecode n.×Ö½ÚÂ룬×Ö½Ú´úÂë
verifier n. ¼ìÑé»ú
modifier [‘mɔdifaiə] n.ÐÞÊÎÓï
attribute [‘ætribju:t] vt.(to)°Ñ…¹éÒòÓÚn.ÊôÐÔ£¬ÌØÐÔ
declaration ......
2009Äê7ÔÂÎҲμÓÁËÒ»¸öJAVAרҵ»ú¹¹µÄÅàѵ£¬Ö®ËùÒԲμÓÕâ¸öÅàѵ£¬ÎÒÊÇΪÁ˽øÒ»²½ÌáÉý×Ô¼ºµÄ¼¼Êõ£¬ÁíÒ»·½ÃæÎÒÒ²±È½Ïϲ»¶JAVA£¬Ï£ÍûËüÄܳÆΪÎҵļ¼ÊõÖ÷Á¦¡£×ªÑÛ£¬Åàѵ¾Í¿ì½áÊøÁË£¬ÐÄÖиÐÎòÁ¼¶à£¬Ï£ÍûÓë¾ý¹²Ãã¡£
ÎÒËù²Î¼ÓµÄÅàѵ»ú¹¹Ö»ÓÐÒ»¸öÀÏʦ£¬²»ÏñºÜ¶àµØ·½ÓкöàµÄÀÏʦ£¬Ã¿Ììÿһ½Ú¿Î¶¼ÊÇËûÀ´¸ ......
Êý×éÊôÒýÓÃÀàÐÍ£¬Êý×éÐÍÊý¾ÝÊǶÔÏó(object)£¬Êý×éÖеÄÿ¸öÔªËØÏ൱ÓڸöÔÏóµÄ³ÉÔ±±äÁ¿
Êý×éÖеÄÔªËØ¿ÉÒÔÊÇÈκÎÊý¾ÝÀàÐÍ£¬°üÀ¨»ù±¾ÀàÐͺÍÒýÓÃÀàÐÍ
¼ÇסÊý×éÊ×ÏÈ·ÖÅä¿Õ¼äÔÙ¸³Öµ£¡
¶¯Ì¬³õʼ»¯£º¾ÍÊÇÏÈ·ÖÅä¿Õ¼äÔÙ¸³³õÖµ£»
¾²Ì¬³õʼ»¯£º¶¨ÒåÊý×éͬʱ¾ÍΪÊý×éÔªËØ·ÖÅä¿Õ¼ä²¢¸³Öµ¡£
1һάÊý×éµÄÉùÃ÷
һάÊý×éµÄÉùÃ÷£ºtype va ......