Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVA²¢·¢±à³Ì±Ê¼Ç£¨3£©

Publication and Escape ·¢²¼Ò»¸ö¶ÔÏóÒâζ×ÅÄܹ»´ÓËüÄܹ»´ÓËüµ±Ç°·¶Î§Ö®Íâ±»·ÃÎʵ½¡£±ÈÈ磬±£´æ¿ÉÒÔ±»ÆäËû´úÂëÕÒµ½µÄÕâ¸ö¶ÔÏóµÄÒ»¸öÒýÓ㬻òÕß½«Æä×÷Ϊһ¸ö·Ç˽Óз½·¨µÄ·µ»ØÖµ£¬»òÕß½«Æä×÷Ϊ²ÎÊý´«µÝ¸øÆäËüµÄÀà¡£ public static Set<Secret> knownSecrets;
public void initialize() {
knownSecrets = new HashSet<Secret>();
}
Õâ¸öknownSecrets¾Í±»·¢²¼ÁË£¬²¢ÇÒ£¬knownSecretsÀïÃæÌí¼ÓµÄËùÓÐsecretÒ²¶¼±»·¢²¼³öÈ¥ÁË¡£
class UnsafeStates {
private String[] states = new String[] {
"AK", "AL" ...
};
public String[] getStates() { return states; }
}
Õâ¸östates¾Í±»·¢²¼ÁË£¬¶øÇÒ´øÀ´µÄÎÊÌâÊÇÈκε÷ÓÃÕ߶¼Äܹ»ÐÞ¸ÄÀïÃæµÄÄÚÈÝ£¬ÕâÑù£¬ºÜ²»°²È«¡£
public class ThisEscape {
public ThisEscape(EventSource source) {
source.registerListener(
new EventListener() {
public void onEvent(Event e) {
doSomething(e);
}
});
}
}
¿´Ã÷°×Õâ¸öThisEscapeΪʲô±»·¢²¼ÁËô£¿ÒòΪËü·¢²¼ÁËEventListener£¬¶øÄÚ²¿Àà»á´øÓÐÒ»¸öÒþʽµÄ¶ÔÍⲿÀàµÄÒýÓá£
ÁíÍ⣬ÉÏÃæÕâ¸öÀàµÄÒ»¸öÑÏÖØÎÊÌâÊÇ£¬ÔÚ¹¹Ôì·½·¨ÖÐthisÒýÓÃescapeÁË¡£ÕâÒ²¾ÍÒâζ×ÅÕâ¸ö¶ÔÏóÔÚ±»·¢²¼µÄʱºò»¹´¦ÓÚÒ»¸ö²»ÍêÕûµÄ״̬¡£Ò»¸ö³£¼ûµÄÇéÐξÍÊÇÔÚÀàµÄ¹¹Ôì·½·¨ÖÐÆô¶¯Ò»¸öÏ̡߳£When an object creates a thread from its constructor, it almost always shares its this reference with the new thread, either explicitly (by passing it to the constructor) or implicitly (because the Thread or Runnable is an inner class of the owning object). µ±È»Õâ±¾ÉíûʲôÎÊÌ⣬µ«×îºÃ²»ÒªÔÚ¹¹Ôì·½·¨ÖоÍÆô¶¯Õâ¸öỊ̈߳¬¶øÊÇ°ÑThread.start()·Åµ½Ò»¸öµ¥¶ÀµÄinit·½·¨Öй©ÆäËü¶ÔÏóµ÷Óá£
Òª±ÜÃâ²»ÍêÈ«¹¹ÔìµÄÎÊÌ⣬¿ÉÒÔ²ÉÓÃÏÂÃæµÄ·½Ê½£º
public class SafeListener {
private final EventListener listener;
private SafeListener() {
listener = new EventListener() {
public void onEvent(Event e) {
doSomething(e);
}
};
}
public static SafeListener newInstance(EventSource source) {
SafeListener safe =


Ïà¹ØÎĵµ£º

ת£ºJavaѧϰ·Ïßͼ£¬×¨ÎªÐÂÊÖ¶¨ÖƵÄJavaѧϰ¼Æ»®½¨Òé

ת×Ô£ºhttp://tieba.baidu.com/f?kz=692446591
ÔõôѧϰJava£¬ÕâÊǺܶàÐÂÊÖ¾­³£»áÎÊÎÒµÄÎÊÌ⣬ÏÖÔÚÎÒ¼òµ¥ÃèÊöÏÂÒ»¸öJava³õѧÕßµ½¾ÍҵҪѧµ½µÄһЩ¶«Î÷£º
    Ê×ÏÈÒªÃ÷°×JavaÌåϵÉè¼Æµ½µÃÈý¸ö·½Ã棺J2SE,J2EE,J2ME£¨KJAVA£©¡£J2SE£¬Java 2 Platform Standard Edition£¬ÎÒÃǾ­³£Ëµµ½µÄJDK£¬¾ÍÖ÷ÒªÖ¸µÄÕâ¸ö£ ......

Java±à³Ì¹æ·¶

Ò»¡¢ÏîÄ¿°æ±¾¹æ·¶£º
1¡¢°æ±¾ºÅÃüÃû¸ñʽ£º
V Ö÷°æ±¾ºÅ.´Î°æ±¾ºÅ.ÐÞÕû°æ±¾ºÅ
a£®³õʼ°æ±¾ºÅΪV1.0.0£»
b£®ÀàÊôÐÔ»òÀà·½·¨µÄÄÚÈÝ·¢Éú±ä»¯Ê±£¬Ö÷°æ±¾ºÅºÍ´Î°æ±¾ºÅ¶¼²»±ä£¬ÐÞÕû°æ±¾ºÅ¼Ó 1£»
c£®Ôö¼ÓÁËÀà»ò½Ó¿Ú·½·¨Ê±£¬Ö÷°æ±¾ºÅ²»±ä£¬´Î°æ±¾ºÅ¼Ó 1£¬ÐÞÕû°æ±¾ºÅ¸´Î»Îª0£»
d£®Ôö¼ÓÁËÀà»ò½Ó¿Úʱ£¬Ö÷°æ±¾ºÅ¼Ó1£¬´Î°æ±¾ºÅ¸´Î»Îª0 ......

Java±ÊÊÔÌ⡾ת¡¿

1.д³ö³ÌÐòÔËÐнá¹û
  
public
class
TestString {
    public
static
void
link(String a){
         a+="World"
;
    }
    public
static
void
main(String []a ......

JavaÖÐthrowºÍthrowsµÄÇø±ð

ϵͳ×Ô¶¯Å׳öµÄÒì³£
ËùÓÐϵͳ¶¨ÒåµÄ±àÒëºÍÔËÐÐÒì³£¶¼¿ÉÒÔÓÉϵͳ×Ô¶¯Å׳ö£¬³ÆΪ±ê×¼Òì³££¬²¢ÇÒ Java Ç¿ÁÒµØÒªÇóÓ¦ÓóÌÐò½øÐÐÍêÕûµÄÒì³£´¦Àí£¬¸øÓû§ÓѺõÄÌáʾ£¬»òÕßÐÞÕýºóʹ³ÌÐò¼ÌÐøÖ´ÐС£
Óï¾äÅ׳öµÄÒì³£
Óû§³ÌÐò×Ô¶¨ÒåµÄÒì³£ºÍÓ¦ÓóÌÐòÌض¨µÄÒì³£,±ØÐë½èÖúÓÚ throws ºÍ throw Óï¾äÀ´¶¨ÒåÅ׳öÒì³£¡£
throwÊÇÓï¾äÅ׳ö ......

¡¾·Ü¶·µÚÒ»Ìì¡¿²ËÄñѧϰJavaÖ®ÎÒµÄÃæÏò¶ÔÏó¹Û


´óѧÁ½ÄêÁË£¬Ò»Ö±»ë»ëجج£¬×î½üÉÏÁËһЩѧϰÂÛ̳£¬·¢ÏÖ×Ô¼ºµÄ֪ʶ̫ØÑ·¦ÁË£¬¸Ð¾õÔõôµÄ×Ô¼ºÒ²ÊǸöÈí¼þרҵµÄѧÉú£¬Ñ§ÁËÁ½Äê½²µ½Ó¦ÓÃȴʲô¶¼²»»á£¬ÓÚÊÇÎÒ¾õµÃ¿ªÊ¼·Ü¶·µÄÈËÉú£¡£¡£¡ÓÚÊÇÎÒÑ¡ÔñÁËJavaÕâôÓïÑÔ×÷ΪÎҷܶ·µÄÆðµã£¬Ô­ÒòºÜ¶à£¬µÚÒ»£¬ÔÚ´óѧѧ¹ýCºÍC++£¨Ö»ÊÇѧ¹ý£¬Ñ§µÄºÜ²»ºÃ£©£¬ËùÒÔÓеã±à³ÌµÄ»ù´¡°É£¬µÚ¶þ£¬Ja ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ