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

JAVAÓÅ»¯±à³Ì


java´úÂëÓÅ»¯±à³Ì
1.JVM ¹ÜÀíÁ½ÖÖÀàÐ͵ÄÄÚ´æ:¶ÑÄÚ´æ(heap),Õ»ÄÚ´æ(stack),¶ÑÄÚÔÚÖ÷ÒªÓÃÀ´´æ´¢³ÌÐòÔÚÔËÐÐʱ´´½¨»òʵÀý»¯µÄ¶ÔÏóÓë±äÁ¿.¶øÕ»ÄÚ´æÔòÊÇÓÃÀ´´æ´¢³ÌÐò´úÂëÖÐÉùÃ÷Ϊ¾²Ì¬(static)(»ò·Ç¾²Ì¬)µÄ·½·¨.
2.JVM ÖжÔÏóµÄÉúÃüÖÜÆÚ,´´½¨½×¶Î,Ó¦Óý׶Î,²»¿ÉÊӽ׶Î,²»¿Éµ½´ï½×¶Î,¿ÉÊÕ¼¯½×¶Î,ÖÕ½á½×
¶Î,ÊͷŽ׶Î
3.±ÜÃâÔÚÑ­»·ÌåÖд´½¨¶ÔÏó,¼´Ê¹¸Ã¶ÔÏóµãÓÃÄÚ´æ¿Õ¼ä²»´ó.
for(int i=0;i<10000;++i){
Object obj = new Object();
System.out.println("obj="+obj);
}
Ó¦¸Ä³É
Object obj = null;
for(int i=0;i<10000;++i){
obj = new Object();
System.out.println("obj="+obj);
}
4.ÈíÒýÓõÄÖ÷ÒªÌصãÊǾßÓнÏÇ¿µÄÒýÓù¦ÄÜ.Ö»Óе±ÄÚ´æ²»¹»µÄʱºò,²Å»ØÊÕÕâÀàÄÚ´æ,Òò´ËÔÚ
ÄÚ´æ×ã¹»µÄʱºò,ËüÃÇͨ³£²»±»»ØÊÕ.Ëü¿ÉÒÔÓÃÓÚʵÏÖһЩ³£ÓÃ×ÊÔ´µÄ»º´æ,ʵÏÖCache µÄ¹¦ÄÜ
A a = new A();
SoftReference sr = new SoftReference(a);
a = null;
if(sr !=null){
a = sr.get();
}else{
a = new A();
sr = new SoftReference(a);
}
5.ÈõÒýÓöÔÏóÓëSoft ÒýÓöÔÏó×î´ó²»Í¬¾ÍÔÚÓÚ:GC ÔÚ½øÐлØÊÕʱ,ÐèҪͨ¹ýËã·¨¼ì²éÊÇ·ñ»Ø
ÊÕSoft ÒýÓöÔÏó,¶ø¶ÔÓÚWeak ÒýÓöÔÏó,GC ×ÜÊǽøÐлØÊÕ.
A a = new A();
WeakReference wr = new WeakReference(a);
a = null;
if(sr !=null){
a = wr.get();
}else{
a = new A();
wr = new WeakReference(a);
}
6.¹²Ïí¾²Ì¬±äÁ¿´æ´¢¿Õ¼ä
7.ÓÐʱºòÎÒÃÇΪÁËÌá¸ßϵͳÐÔÄÜ,±ÜÃâÖظ´ºÄʱµÄ²Ù×÷,Ï£ÍûÄܹ»ÖØÓÃһЩ´´½¨Íê³ÉµÄ¶ÔÏó,Àû
ÓöÔÏó³ØʵÏÖ.ÀàËÆJDBC Á¬½Ó³Ø.
8.˲¼äÖµ,ÐòÁл¯¶ÔÏó´ó±äÁ¿Ê±,Èç¹û´Ë´ó±äÁ¿ÓÖûÓÐÓÃ;,ÔòʹÓÃtransient ÉùÃ÷,²»ÐòÁл¯´Ë±ä
Á¿.ͬʱÍøÂç´«ÊäÖÐÒ²²»´«Êä.
9.²»ÒªÌáÇ°´´½¨¶ÔÏó
void f(){
int i;
A a = new A();
if(....){
a.showMessage();
}
}
¸Ä³É
void f(){
int i;
A a = null;
if(....){
//Óõ½Ê±²ÅʵÀý»¯
a = new A();
a.showMessage();
}
}
10 .(1)×î»ù±¾µÄ½¨Òé¾ÍÊǾ¡ÔçÊÍ·ÅÎÞÓöÔÏóµÄÒýÓÃ
A a = new A();
a = null; //µ±Ê¹ÓöÔÏóa Ö®ºóÖ÷¶¯½«ÆäÉèÖÃΪ¿Õ
(2)¾¡Á¿ÉÙÓÃfinalize º¯Êý.
(3) Èç¹ûÐèҪʹÓþ­³£Óõ½µÄͼƬչ,¿ÉÒÔʹÓÃÈíÒýÓÃ.
(4) ×¢Ò⼯ºÏÊý¾ÝÀàÐÍ,°üÀ¨Êý×é,Ê÷µÈÊý¾Ý,ÕâЩÊý¾Ý½á¹¹¶ÔGC À´Ëµ,»ØÊÕ¸üΪ¸´ÔÓ,
(5) ¾¡Á¿±ÜÃâÔÚÀàµÄĬÈϹ¹ÔìÆ÷Öд´½¨,³õʼ»¯´óÁ¿µÄ¶ÔÏó,·ÀÖ¹ÔÚµ÷ÓÃÆä×ÔÀàµÄ¹¹ÔìÆ÷
ʱÔì³É²»±ØÒªµÄÄÚ´æ×ÊÔ´ÀË·Ñ.
(6) ¾¡Á¿±ÜÃâÇ¿ÖÆϵͳ×ö


Ïà¹ØÎĵµ£º

Java»ñÈ¡¿Í»§¶ËÕæʵIPµØÖ·µÄÁ½ÖÖ·½·¨

ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr£¨£©£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ö϶¼ÊÇÓÐЧµÄ¡£µ«ÊÇÔÚͨ¹ýÁËApache£¬SquidµÈ·´Ïò´úÀíÈí¼þ¾Í²»ÄÜ»ñÈ¡µ½¿Í»§¶ËµÄÕæʵIPµØÖ·ÁË¡£
¡¡¡¡
Tag£ºJava ¿Í»§¶Ë ÕæʵIPµØÖ·
ÔÚJSPÀ»ñÈ¡¿Í»§¶ËµÄIPµØÖ·µÄ·½·¨ÊÇ£ºrequest.getRemoteAddr£¨£©£¬ÕâÖÖ·½·¨Ôڴ󲿷ÖÇé¿ ......

java²Ù×÷Excel

½«ÏÂÔغóµÄÎļþ½â°ü£¬µÃµ½jxl.jar£¬·ÅÈëclasspath£¬°²×°¾ÍÍê³ÉÁË¡£
»ù±¾²Ù×÷
Ò»¡¢´´½¨Îļþ
ÄâÉú³ÉÒ»¸öÃûΪ“²âÊÔÊý¾Ý.xls”µÄExcelÎļþ£¬ÆäÖеÚÒ»¸ö¹¤×÷±í±»ÃüÃûΪ“µÚÒ»Ò³”£¬´óÖÂЧ¹ûÈçÏ£º
´úÂ루CreateXLS.java£©£º
//Éú³ÉExcelµÄÀà
import java.io.*;
import jxl.*;
import jxl.write. ......

java±ÊÊÔ1

1. HttpSession session = request.getSession() 
ÓëHttpSession session = request.getSession(true)µÄÇø±ð£¿ 
²Î¿¼´ð°¸£º 
getSession(true)µÄº¯ÊýÔ­ÐÍΪ:£ºHttpSession session = request.getSession (Boolean create) 
Èç¹ûÓÐÓ뵱ǰµÄrequestÏȹØÁªµÄHttpSession,ÄÇô·µ»ØrequestÏà¹ØÁªµÄHttpS ......

´«ÖDz¥¿ÍJavaÅàѵ Servlet

ÔçÉÏÆð´²ÓеãÍíÁË£¬µ½Ñ§Ð£µÃʱºò¶¼8£º50ÁË£¬Ò»½ø½ÌÊÒ¿´¼ûÕÅТÏéÀÏʦÔÚ½ÌÊÒÀï¸øͬѧÃǽâ¾öÎÊÌ⣬²»¼ûÁËÀϱϵÄÉíÓ°£¬»¹ÒÔΪ×ß´í½ÌÊÒÁËÄØ£¬°´Àí˵Õâ¸öʱºòÀϱÏÓ¦¸ÃÔçÀ´Á˲ÅÊÇ£¬Ò»ÎʲÅÖªµÀÊDZÏÀÏʦ²¡ÁË,È¥Ò½Ôº¼ì²éÈ¥ÁË£¬Ï£Íû±ÏÀÏʦÄÜÔçµãºÃÆðÀ´£¡
½ñÌìÊÇÕÅÀÏʦ¸øÎÒÃÇÉϿΣ¬ÉîÈëÆÊÎöservlet£¬ÔÚûÀ´´«ÖDz¥¿Í֮ǰ¿´¹ý²»ÉÙÒÔÇ°ÕÅÀ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ