javaÖеÄstringÀàÐÍÈ«Ãæ½âÎö
1. Ê×ÏÈString²»ÊôÓÚ8ÖÖ»ù±¾Êý¾ÝÀàÐÍ£¬StringÊÇÒ»¸ö¶ÔÏó¡£
¡¡¡¡ÒòΪ¶ÔÏóµÄĬÈÏÖµÊÇnull£¬ËùÒÔStringµÄĬÈÏÖµÒ²ÊÇnull£»µ«ËüÓÖÊÇÒ»ÖÖÌØÊâµÄ¶ÔÏó£¬ÓÐÆäËü¶ÔÏóûÓеÄһЩÌØÐÔ¡£
¡¡¡¡2. new String()ºÍnew String(“”)¶¼ÊÇÉêÃ÷Ò»¸öеĿÕ×Ö·û´®£¬ÊÇ¿Õ´®²»ÊÇnull£»
¡¡¡¡3. String str=”kvill”£»
String str=new String (“kvill”);µÄÇø±ð£º
¡¡¡¡ÔÚÕâÀÎÒÃDz»Ì¸¶Ñ£¬Ò²²»Ì¸Õ»£¬Ö»Ïȼòµ¥ÒýÈë³£Á¿³ØÕâ¸ö¼òµ¥µÄ¸ÅÄî¡£
¡¡¡¡³£Á¿³Ø(constant pool)Ö¸µÄÊÇÔÚ±àÒëÆÚ±»È·¶¨£¬²¢±»±£´æÔÚÒѱàÒëµÄ.classÎļþÖеÄһЩÊý¾Ý¡£Ëü°üÀ¨Á˹ØÓÚÀà¡¢·½·¨¡¢½Ó¿ÚµÈÖеij£Á¿£¬Ò²°üÀ¨×Ö·û´®³£Á¿¡£
¡¡¡¡¿´Àý1£º
String s0=”kvill”;
String s1=”kvill”;
String s2=”kv” + “ill”;
System.out.println( s0==s1 );
System.out.println( s0==s2 );
¡¡¡¡½á¹ûΪ£º
true
true
¡¡¡¡Ê×ÏÈ£¬ÎÒÃÇÒªÖªµÀJava»áÈ·±£Ò»¸ö×Ö·û´®³£Á¿Ö»ÓÐÒ»¸ö¿½±´¡£
¡¡¡¡ÒòΪÀý×ÓÖеÄs0ºÍs1ÖеĔkvill”¶¼ÊÇ×Ö·û´®³£Á¿£¬ËüÃÇÔÚ±àÒëÆھͱ»È·¶¨ÁË£¬ËùÒÔs0==s1Ϊtrue£»¶ø”kv”ºÍ”ill”Ò²¶¼ÊÇ×Ö·û´®³£Á¿£¬µ±Ò»¸ö×Ö·û´®Óɶà¸ö×Ö·û´®³£Á¿Á¬½Ó¶ø³Éʱ£¬Ëü×Ô¼º¿Ï¶¨Ò²ÊÇ×Ö·û´®³£Á¿£¬ËùÒÔs2ҲͬÑùÔÚ±àÒëÆھͱ»½âÎöΪһ¸ö×Ö·û´®³£Á¿£¬ËùÒÔs2Ò²Êdz£Á¿³ØÖДkvill”µÄÒ»¸öÒýÓá£
¡¡¡¡ËùÒÔÎÒÃǵóös0==s1==s2;
¡¡¡¡ÓÃnew String() ´´½¨µÄ×Ö·û´®²»Êdz£Á¿£¬²»ÄÜÔÚ±àÒëÆÚ¾ÍÈ·¶¨£¬ËùÒÔnew String() ´´½¨µÄ×Ö·û´®²»·ÅÈë³£Á¿³ØÖУ¬ËüÃÇÓÐ×Ô¼ºµÄµØÖ·¿Õ¼ä¡£
¡¡¡¡¿´Àý2£º
String s0=”kvill”;
String s1=new String(”kvill”);
String s2=”kv” + new String(“ill”);
System.out.println( s0==s1 );
System.out.println( s0==s2 );
System.out.println( s1==s2 );
¡¡¡¡½á¹ûΪ£º
false
false
false
¡¡¡¡Àý2ÖÐs0»¹Êdz£Á¿³ØÖДkvill”µÄÓ¦Óã¬s1ÒòΪÎÞ·¨ÔÚ±àÒëÆÚÈ·¶¨£¬ËùÒÔÊÇÔËÐÐʱ´´½¨µÄжÔÏó”kvill”µÄÒýÓã¬s2ÒòΪÓкó°ë²¿·Önew String(“ill”)ËùÒÔÒ²ÎÞ·¨ÔÚ±àÒëÆÚÈ·¶¨£¬ËùÒÔÒ²ÊÇÒ»¸öд´½¨¶ÔÏó”kvill”µÄÓ¦ÓÃ;Ã÷°×ÁËÕâЩҲ¾ÍÖªµÀΪºÎµÃ³ö´Ë½á¹ûÁË¡£
¡¡¡¡4. String.intern()£º
¡¡¡¡ÔÙ²¹³ä½éÉÜÒ»µã£º´æÔÚÓÚ.classÎļþÖеij£Á¿³Ø£¬ÔÚÔËÐÐÆÚ±»JVM×
Ïà¹ØÎĵµ£º
1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾Àý´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ – ÿÖܶ¼ÓÐÐÂÎÄÕ·¢±í.
4.[http ......
×î¼Ñ´ð°¸
1. ±àд·¶ÀýÎĵµ
public class TestNative
{
private native static int Max(int a,int b);
public static void main(String[] args)
{
System.out.println(Max(4,5));
}
static
{
System.loadLibrary("VCdll");
}
}
ÆäÖÐ
LoadLibraryÖеÄDLLÎļþÃû³Æ¿ÉÒÔ ......
Observer
Intent
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
How to
Subject
knows its observers. Any number of Observer objects may observe a subject.
provides an in ......
×Ô¼ºÔÚ×öÕâ¸ö³ÌÐòµÄʱºò¿´¹ýºÜ¶àµÄ×ÊÁÏ£¬ÉÏÍøÒ²²éÁ˲»ÉÙµÄ×ÊÁÏ£¬¿ÉÊǶà°ë˵µÄÊdzöÉñÈ뻯£¬ÔÆÀïÎíÀï...²»¹â¿´Á˲»Ã÷°×£¬¶øÇÒÊÇÓÐÃ÷°×Ò»µãµÄÈË£¬¿´ÁËÒ²±äµÄÓÐЩģºýÁË¡£
ÕâÀïÎÒÑÚÊÎÒ»Ì×ÍêÕûµÄjava jdbc Á¬½ÓOracle9iµÄ·¶Àý¡£
package com.lxh.dbcon;//´ò°ü
import ......