JAVAÐéÄâ»ú×Ö·û´®³ØÏà¹Ø(±Ê¼Ç)
JAVAÐéÄâ»úÓÐÒ»¸ö×Ö·û´®³Ø,¶ÔÓÚ×Ö·û´®³ØµÄ·ÃÎÊ¿ÉÒÔʹÓÃ×Ö·û´®¶ÔÏóµÄintern()·½·¨,¿É¶¯Ì¬Ïò³ØÖÐÌí¼Ó¶ÔÏó,ËüµÄ¶¨ÒåÈçÏÂ:
public native String intern();
ÕâÊÇÒ»¸ö±¾µØ·½·¨,ÔÚµ÷ÓÃÕâ¸ö·½·¨Ê±,JAVAÐéÄâ»úÊ×Ïȼì²é×Ö·û´®³ØÖÐÊÇ·ñ´æÔÚÓë¸Ã×Ö·û´®¶ÔÏóÖµÏàµÈµÄ¶ÔÏó,Èç¹û´æÔھͷµ»Ø×Ö·û´®³ØÖеĶÔÏóµÄÒýÓÃ,·ñÔò¾Íд´½¨Ò»¸öÓë¸Ã×Ö·û´®¶ÔÏóÖµÏàµÈµÄ¶ÔÏó,È»ºóÔÙ·µ»Øд´½¨¶ÔÏóµÄÒýÓÃ,ÓÐÈçÏÂÒ»¶Î´úÂë:
public class InternTest{
public static void main(String args[]){
//ÓÃÒ»¸ö×Ö·ûÊý×é³õʼ»¯a,ÊDZÜÃâ³ØÖк¬ÓÐֵΪ"abcd"µÄ¶ÔÏó
String a=new String(new char[]{'a','b','c','d'});
String b=a.intern();
(1)
if(a==b){
System.out.println("b¼ÓÈëÁË×Ö·û´®³ØÖÐ,ûÓÐн¨¶ÔÏó");
}else{
System.out.println("bû¼ÓÈë×Ö·û´®³ØÖÐ,н¨Á˶ÔÏó");
}
}
}
ÉÏÊö´úÂëÔËÐкó½«Êä³ö"bû¼ÓÈë×Ö·û´®³ØÖÐ,н¨Á˶ÔÏó".ÔÒòÈçÏÂ:
String a=new String(new char[]{'a','b','c','d'});
¸ÃÓï¾ä»áн¨Ò»¸ö×Ö·û´®¶ÔÏó,µ«¸Ã¶ÔÏó²¢²»»á·ÅÈë×Ö·û´®³ØÖУ¬¶øÊÇ·ÅÔÚ¶ÑÖÐ
ͨ¹ýa.intern()Óï¾ä,JVM½«»áÔÚ×Ö·û´®³ØÖÐн¨Ò»¸öֵΪ"abcd"µÄ¶ÔÏó,²¢°ÑÆäÒýÓ÷µ»Ø¸øb,Òò´Ë²ÅÓÐÁËÉÏÃæµÄÊä³ö
Èç¹ûÔÚ´úÂëÖÐ(1)´¦¼ÓÈëÓï¾ä:String c="abcd";
ÄÇôSystem.out.println(c==b);»á·µ»Øtrue
Ç°Ãæ̸µ½String¶ÔÏóµÄ´æ´¢,ÔÚJAVAÖÐ,Õ»(stack)Ö÷Òª±£´æ»ù±¾ÀàÐÍ,ËٶȽö´ÎÓڼĴæÆ÷,±È¶ÑÒª¿ì,¶ø¶Ñ(heap)Ö÷ÒªÓÃÓÚ´æ´¢¶ÔÏó;
ÔÚÓÃÒýºÅ´´½¨×Ö·û´®¶ÔÏóʱ,ʵ¼ÊÉÏÊÇJAVAÐéÄâ»úÔÚÕ»Öд´½¨¶à¸öcharÐÍ×Ö·û,È»ºóÔÚ¶ÑÖд´½¨Ò»¸öString¶ÔÏó,¸Ã¶ÔÏóµÄÖµ¾ÍÊÇ֮ǰջÖеÄÄǸö×Ö·ûÐòÁÐ;¶øÓÃnew String("abc")´´½¨String¶ÔÏóʱ,¹Ø¼ü×Önew»á´´½¨Ò»¸ö×Ö·û´®¶ÔÏó·ÅÔÚ¶ÑÖÐ,"abc"Ò²»á´´½¨Ò»¸ö×Ö·û´®¶ÔÏó,µ«¸Ã
Ïà¹ØÎĵµ£º
ÎÊÌâÃèÊö
Exception in thread "main" java.lang.OutOfMemoryError:
Java heap space
½â¾ö·½°¸[ת]
Ò»Ö±¶¼ÖªµÀ¿ÉÒÔÉèÖÃjvm heap´óС£¬Ò»Ö±ÓÃeclipseд/µ÷ÊÔjava³ÌÐò¡£Ò»Ö±ÓÃÃüÁîÐÐor
console¼Ó²ÎÊýÅܳÌÐò¡£ÏÖÏó£ºÔÚeclipseµÄÅäÖÃÎļþeclipse.iniÖÐÉèÖÃ-vmargs -Xms500m
-Xmx1024m
£¬ÔÚeclipseÖ ......
¶ÔÓÚ10½øÖÆÊýת»»ÎªN£¨2-36£©½øÖÆÒ»°ã¶¼ÊÇÑ¡ÔñÈ¡Óà³ýµÄËã·¨½øÐÐת»» £¬ÏÂÃæ¸ø³öÁ½ÖÖ·½°¸
Ò»ÖÖÊǵݹ飬һÖÖÊǵü´ú¡£Í¨¹ýЧÂÊÆÀ¼ÛÁ½ÕßÐÔÄÜ
ÆäÖеü´úµÄ·½°¸Ö±½ÓÈ¡×ÔjavaÔ´´úÂë¡£
/*
*Class NotationConvert.java
*Create Date: 2009-11-12
*Author:a276202460
*/
package com.rich.notation;
public class Notat ......
pythonÕýÎÄ£º ºÍÆäËüÓïÑÔÒ»Ñù£¬ÎÒÃÇ¿ÉÒÔÒÔÃüÁîÐеÄÐÎʽ¸øÄãµÄpython³ÌÐò´«µÝ²ÎÊý£¬pyhtonÄܹ»×Ô¶¯°ÑÃüÁîÐвÎÊýÒÔ×Ö·û´®ÁбíµÄÐÎʽ´æ´¢ÔÚsysÄ£¿éµÄarv±äÁ¿¡£ok£¬ÎÒÃÇÏÈÀ´¿´¸öÀý³Ì£º
# ÎļþÃû: printargs.py
#ÓÃ;£ºÑÝʾpythonµÄ´«²Î
import sys
print sys.argv
ÔÚÃü ......
Java ÖиøÊý×Ö×ó±ß²¹0 £¨1£©·½·¨Ò»
import java.text.NumberFormat; public class NumberFormatTest { public static void main(String[] args) {
//´ý²âÊÔÊý¾Ý
int i = 1;
......
CoreJava¶àÏß³Ì
Ï̵߳ĸÅÄ
Ïß³ÌÖ¸½ø³ÌÖеÄÒ»¸öÖ´ÐÐÁ÷³Ì£¬Ò»¸ö½ø³Ì¿ÉÒÔ°üº¬¶à¸öÏ̡߳£
ÿһ¸ö½ø³Ì¶¼¶ÀÏíÒ»¿éÄÚ´æ¿Õ¼ä¡£Ã¿¸ö½ø³Ì¶¼ÐèÒª²Ù×÷ϵͳΪÆä·ÖÅä¶ÀÁ¢µÄÄÚ´æµØÖ·£¬¶øͬһ½ø³ÌÖеĶà¸öÏß³ÌÔÚͬһ¿éµØÖ·¿Õ¼ä¹¤×÷£¬ËûÃǹ²ÏíÒ»¿éÄÚ´æºÍ×ÊÔ´¡£
javaÖÐÓÐÁ½Öз½·¨´´½¨Ò»¸ö¶àÏß³ÌÀࣺ
1¡¢¼Ì³Ðjava.lang.ThreadÀ࣬¸²¸ÇT ......