Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Çå³ýhtml¸ñʽÕýÔò±í´ïʽ


 public static String splitAndFilterString(String input, int length) {   
        if (input == null || input.trim().equals("")) {   
     &nb ......

javaÃæÊÔÌâ2

ÎÒÃÇ´ó¼Ò¶¼ÖªµÀ£¬¶ÔÓÚ¾²Ì¬±äÁ¿¡¢¾²Ì¬³õʼ»¯¿é¡¢±äÁ¿¡¢³õʼ»¯¿é¡¢¹¹ÔìÆ÷£¬ËüÃǵijõʼ»¯Ë³ÐòÒÔ´ËÊÇ£¨¾²Ì¬±äÁ¿¡¢¾²Ì¬³õʼ»¯¿é£©>£¨±äÁ¿¡¢³õʼ»¯¿é£©>¹¹ÔìÆ÷¡£ÎÒÃÇÒ²¿ÉÒÔͨ¹ýÏÂÃæµÄ²âÊÔ´úÂëÀ´ÑéÖ¤ÕâÒ»µã£º
public class InitialOrderTest {
// ¾²Ì¬±äÁ¿
public static String staticField = "¾²Ì¬±äÁ¿";
// ±äÁ¿
......

´«ÖDz¥¿ÍJAVAÅàѵOAÏîÄ¿2010 5 12


´«ÖDz¥¿ÍJAVAÅàѵOAÏîÄ¿2010-5-12
½ñÌì»»Á˸öнÌÊÒ£¬ÖÕÓÚ½áÊøÁËÃÆÈȵĿÕÆøÁË¡£ÒÔÇ°½ÌÊÒ¿Õµ÷´ó´óµÄÓÐÎÊÌ⣬ÏÖÔÚºÃÁË£¬¿ÉÒÔÒ»Ïí¿Õµ÷µÄÁ¹Ë¬£¬Ö»²»ÊÇΨһÃÀÖв»×ãµÄÊÇ£¬¾ÓÈ»ÓõIJ»ÊǸñÁ¦¿Õµ÷¡£ÔÚ¸ñÁ¦¿Õµ÷´ôÁËËÄÄ꣬ËäÈ»ÔÚÄǶùûÓз¢»Ó³öÎÒ¸üºÃµÄˮƽ£¬µ«ÊÇÈ˱Ͼ¹ÊÇÓиÐÇéµÄ£¬ÎÒÒ²ºÜ°®ÄǸö¸ñÁ¦£¬´ó¹«Ë¾£¬´óÆøÆÇ£¬ÌرðÊÇ£¬ÎÒà ......

ArrayListÖеÄÊý¾ÝÅÅÐò java¶ÔÏóÅÅÐò

³£³£Óöµ½Êý×éÅÅÐòµÄÎÊÌâ.±ÈÈçÎÒÓÐÒ»¸öPersonÀà,ËüµÄʵÀý¶ÔÏó´æ´¢ÔÚArrayListÊý×éÖÐ,ÏÖÔÚÒª°ÑArrayListÊý×éÖеÄPerson¶ÔÏó°´ÕÕÄêÁäÅÅÐò.
ÆäʵÕâÖÖÇé¿ö¾­³£Óöµ½.
ÏÂÃæ¸ø³öÔ´´úÂë:
1:Person.JavaÎļþ:-------------------------------
public class Person{
String name;
int age;
public Person(String name,int age){ ......

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

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