天天看點

java面試百題

? 1???㈠??瀵矽薄???瑰?????浜??歸????

(1).?借薄锛?

?借薄灏辨??蹇界?ヤ?涓?涓婚?涓?涓?褰??????????崇???d??歸???浠ヤ究?村?????版敞??涓?褰??????????崇???歸?????借薄骞朵???绠?浜?瑙e?ㄩ?ㄩ??棰?锛??????????╁?朵腑??涓??ㄥ??锛????朵??ㄩ?ㄥ??缁??????借薄????涓や釜?歸???涓???杩?绋??借薄锛?浜????版???借薄??

(2).缁ф?匡?

缁ф?挎??涓?绉???缁?绫葷??灞?娆℃ā??锛?骞朵???璁稿??榧??辯被???????瀹???渚?浜?涓?绉???纭?琛ㄨ堪?辨?х???規???瀵矽薄??涓?涓??扮被??浠ヤ??版????绫諱腑娲劇??锛?杩?涓?杩?绋?绉頒負绫葷戶?褲???扮被缁ф?誇???濮?绫葷???規?э??扮被绉頒負??濮?绫葷??娲劇??绫夥?瀛?绫夥?锛?????濮?绫葷О涓烘?扮被???虹被锛??剁被锛???娲劇??绫誨??浠ヤ?瀹????虹被?i??缁ф?挎?規???瀹?渚?????锛?骞朵?绫誨??浠ヤ慨?規??澧????扮???規?浣誇??撮?????規??????瑕???

(3).灏?瑁?锛?

灏?瑁?????杩?绋????版?????磋搗?ワ?瀵規?版????璁塊?????介??杩?宸插??涔??????????㈠??瀵矽薄璁$??濮?浜?杩?涓??烘??姒?蹇碉??崇?闆??涓?????浠ヨ???缁???涓?绯誨??瀹??ㄨ??娌彙??灏?瑁???瀵矽薄锛?杩?浜?瀵矽薄??杩?涓?涓???淇??ょ???ュ?h?塊???朵?瀵矽薄??

(4). 澶????э?

澶????ф??????璁鎬???绫葷??瀵矽薄瀵瑰??涓?娑???浣??哄??搴???澶????у???????闆??澶????у??????澶????с??澶????ц??瑷??鋒???墊椿???借薄??琛?涓哄?變韓??浠g???變韓??浼??匡?寰?濂界??瑙e?充?搴??ㄧ?搴??芥?闆??????棰??? 2 ??String?????烘?????版??绫誨?????

?烘???版??绫誨??????byte??int??char??long??float??double??boolean??short??

java.lang.String绫繪??final绫誨????锛???姝や???浠ョ戶?胯?涓?绫彙??涓??戒慨?矽?涓?绫彙??涓轟???楂?????????绌洪?達???浠?搴?璇ョ??tringBuffer绫?3??int ?? Integer ??浠?涔??哄??

Java ??渚?涓ょ?涓?????绫誨??锛?寮??ㄧ被??????濮?绫誨??锛?????缃?绫誨??锛???Int??java????濮??版??绫誨??锛?Integer??java涓?nt??渚???灏?瑁?绫彙??Java涓烘??涓???濮?绫誨????渚?浜?灏?瑁?绫彙??

??濮?绫誨??灏?瑁?绫?booleanBoolean

charCharacter

byteByte

shortShort

intInteger

longLong

floatFloat

doubleDouble

寮??ㄧ被??????濮?绫誨????琛?涓哄???ㄤ???锛?骞朵?瀹?浠??鋒??涓?????璇?涔???寮??ㄧ被??????濮?绫誨???鋒??涓??????瑰????ㄦ?锛?瀹?浠?????锛?澶у?????搴???棰?锛?杩?绉?绫誨??浠ュ??绉?绫誨?????版??缁???瀛????褰?寮??ㄧ被??????濮?绫誨???ㄤ???涓?绫葷??瀹?渚??版???舵????瀹???缂虹???箋??瀵矽薄寮??ㄥ??渚???????缂虹???間負 null锛?????濮?绫誨??瀹?渚???????缂虹???間?瀹?浠???绫誨?????熾??

4??String ??StringBuffer???哄??

JAVA骞沖?版??渚?浜?涓や釜绫夥?String??StringBuffer锛?瀹?浠???浠ュ?ㄥ??????浣?瀛?绗?覆锛??沖????澶?涓?瀛?绗???瀛?绗??版????杩?涓?String绫繪??渚?浜??闆?間????瑰????瀛?绗?覆????杩?涓?StringBuffer绫繪??渚???瀛?绗?覆杩?琛?淇??廣??褰?浣??ラ??瀛?绗??版??瑕??瑰?????跺??浣?灏卞??浠ヤ嬌??tringBuffer???稿???幫?浣???浠ヤ嬌??tringBuffers?ュ?ㄦ??????瀛?绗??版????

5??杩?琛??跺?甯鎬?涓???寮?甯告??浣?寮???锛?

寮?甯歌〃绀虹?搴?杩?琛?杩?绋?涓????藉?虹?扮????姝e父?舵??锛?杩?琛??跺?甯歌〃绀鴻?????虹????甯告??浣?涓????介???扮??寮?甯革???涓?绉?甯歌?杩?琛???璇???java缂?璇??ㄨ?姹??規?蹇?椤誨0?????哄???藉????????杩?琛??跺?甯革?浣???骞朵?瑕?姹?蹇?椤誨0?????烘??琚????風??杩?琛??跺?甯搞??

6??璇村??ervlet?????藉?ㄦ??锛?骞惰?村??ervlet??CGI???哄????

Servlet琚????″?ㄥ??渚?????锛?瀹瑰?ㄨ?琛???nit?規?锛?璇鋒??拌揪?惰?琛???ervice?規?锛?service?規????ㄦ淳?h?琛?涓?璇鋒?瀵瑰???doXXX?規?锛?doGet锛?doPost锛?绛?锛?褰????″?ㄥ?沖??灏?瀹?渚???姣????跺??璋??ㄥ??estroy?規???

涓?cgi???哄???ㄤ?servlet澶?浜????″?ㄨ?绋?涓?锛?瀹???杩?澶?绾跨??瑰?杩?琛???ervice?規?锛?涓?涓?瀹?渚???浠ユ???′?澶?涓?璇鋒?锛?骞朵??跺??渚?涓???涓?浼???姣?锛???CGI瀵規??涓?璇鋒??戒駭???扮??杩?绋?锛????″??????灏遍??姣?锛???浠ユ????涓?浣?浜?servlet??

7??璇村??rrayList,Vector, LinkedList??瀛??ㄦ?ц?藉???規??ArrayList??Vector?芥??浣跨?ㄦ?扮??瑰?瀛??ㄦ?版??锛?姝ゆ?扮???绱??闆ぇ浜?瀹???瀛??ㄧ???版??浠ヤ究澧????????ュ??绱?锛?瀹?浠??藉??璁哥?存?ユ??搴??風儲寮???绱?锛?浣??????ュ??绱?瑕?娑????扮???绱?绉誨?ㄧ????瀛???浣?锛???浠ョ儲寮??版??蹇??????ユ?版?????Vector?變?浣跨?ㄤ?synchronized?規?锛?绾跨?瀹????锛???甯告?ц?戒?杈?ArrayList宸?锛???LinkedList浣跨?ㄥ?????捐〃瀹??闆???????搴??風儲寮??版????瑕?杩?琛???????????????锛?浣??????ユ?版???跺????瑕?璁闆???椤圭??????椤瑰?沖??锛???浠ユ???ラ??搴??蹇???

8??EJB???轟???浜?????瀹??扮??锛?骞惰?村??essionBean??EntityBean???哄??锛?StatefulBean??StatelessBean???哄????

??? EJB????Session Bean??Entity Bean??Message Driven Bean锛??轟?JNDI??RMI??JAT绛?????瀹??般??

SessionBean??2EE搴??ㄧ?搴?涓?琚??ㄦ?ュ????涓?浜????″?ㄧ????涓??℃??浣?锛?渚?濡?璁塊???版??搴???璋??ㄥ?朵?EJB缁?浠躲??EntityBean琚??ㄦ?ヤ唬琛ㄥ??ㄧ郴缁?涓??ㄥ?扮???版????

瀵逛?瀹㈡?鋒?猴?SessionBean??涓?绉?????涔??у?矽薄锛?瀹?瀹??版??浜??ㄦ???″?ㄤ?杩?琛???涓??¢?昏???

瀵逛?瀹㈡?鋒?猴?EntityBean??涓?绉???涔??у?矽薄锛?瀹?浠h〃涓?涓?瀛??ㄥ?ㄦ??涔??у???ㄥ?ㄤ腑??瀹?浣???瀵矽薄瑙??撅?????涓?涓??辯?版??浼?涓?搴??ㄧ?搴?瀹??扮??瀹?浣???

Session Bean 杩???浠ュ??缁???涓?Stateful Session Bean 涓? Stateless Session Bean 锛?杩?涓ょ??? Session Bean?藉??浠ュ?绯葷??昏??懼??method涔?涓??ц?锛?涓??????? Stateful Session Bean ??浠ヨ?闆??煎???????舵??锛???姝ら??甯告?ヨ?達?涓?涓?浣跨?ㄨ??浼???涓?涓??稿?瑰??? Stateful Session Bean ??瀹?浣???Stateless Session Bean ?界?朵????昏?缁?浠訛?浣???浠??翠?璐?璐h?闆?浣跨?ㄨ???舵??锛?涔?灏辨??璇村?浣跨?ㄨ???煎?? Stateless Session Bean ???跺??锛?EJB Container 骞朵?浼??懼?葷?瑰???? Stateless Session Bean ??瀹?浣??ユ?ц?杩?涓? method???㈣?涔?锛?寰????芥?頒釜浣跨?ㄨ???ㄦ?ц???涓? Stateless Session Bean ?? methods ?訛?浼?????涓?涓? Bean ?? Instance ?ㄦ?ц???浠???瀛??歸?㈡?ョ??锛? Stateful Session Bean 涓? Stateless Session Bean 姣?杈?锛? Stateful Session Bean 浼?娑??? J2EE Server 杈?澶?????瀛?锛??惰?? Stateful Session Bean ??浼??垮?村?ㄤ?浠???浠ョ淮??浣跨?ㄨ?????舵????

9??Collection ?? Collections???哄????

????Collection??????绫葷??涓?绾ф?ュ?o?缁ф?誇?浠????ュ?d富瑕???Set ??List.

Collections????瀵歸????绫葷??涓?涓?甯??╃被锛?浠???渚?涓?绯誨???????規?瀹??闆?瑰??绉?????????绱?????搴???绾跨?瀹??ㄥ??绛???浣???

10??&??&&???哄????

??? &??浣?杩?绠?绗??琛ㄧず??浣?涓?杩?绠?锛?&&???昏?杩?绠?绗??琛ㄧず?昏?涓?锛?and锛???

11??HashMap??Hashtable???哄????

??? HashMap??Hashtable??杞婚??绾у???幫???绾跨?瀹??ㄧ??瀹??幫?锛?浠?浠??藉????浜?Map?ュ?o?涓昏??哄???ㄤ?HashMap??璁哥┖锛?null锛????鹼?key锛?,?變???绾跨?瀹????????涓????介??浜?Hashtable??

HashMap??璁稿?null浣?涓轟?涓?entry??key????value锛???Hashtable涓???璁搞??

HashMap??Hashtable??contains?規??繪??浜?锛??規??containsvalue??containsKey????涓?ontains?規?瀹規??璁╀漢寮?璧瘋??瑙c??

Hashtable缁ф?胯??Dictionary绫夥???HashMap??Java1.2寮?杩???Map interface??涓?涓?瀹??般??

??澶х??涓?????锛?Hashtable???規???Synchronize??锛???HashMap涓???锛??ㄥ?涓?绾跨?璁塊??Hashtable?訛?涓???瑕???宸變負瀹????規?瀹??闆??姝ワ???HashMap 灏卞?椤諱負涔???渚?澶???姝ャ??

Hashtable??HashMap???ㄧ??hash/rehash绠?娉??藉ぇ姒?涓??鳳???浠ユ?ц?戒?浼???寰?澶х??宸?寮???

12??final, finally, finalize???哄????

????final ?ㄤ?澹版??灞??э??規???绫夥?????琛ㄧず灞??т?????锛??規?涓???瑕???锛?绫諱???缁ф?褲??

finally??寮?甯稿???璇??ョ?????涓??ㄥ??锛?琛ㄧず?繪???ц???

finalize??Object绫葷??涓?涓??規?锛??ㄥ???炬?堕???ㄦ?ц????跺??浼?璋??ㄨ????跺?矽薄??姝ゆ?規?锛???浠ヨ???姝ゆ?規???渚????炬?堕???剁???朵?璧?婧????訛?渚?濡??抽????浠剁????

13??sleep() ?? wait() ??浠?涔??哄???

??? sleep??绾跨?绫夥?Thread锛????規?锛?瀵艱?存?ょ嚎绋??????ц???瀹??堕?達?缁??ц??轟?缁??朵?绾跨?锛?浣??????х?舵??渚??朵???锛??版?跺??浼????ㄦ?㈠???璋???leep涓?浼????懼?矽薄????

wait??Object绫葷???規?锛?瀵規?ゅ?矽薄璋???ait?規?瀵艱?存??绾跨??懼?瀵矽薄??锛?杩??ョ??寰?姝ゅ?矽薄??绛?寰???瀹?姹?锛???????瀵規?ゅ?矽薄????otify?規?锛???notifyAll锛?????绾跨???杩??ュ?矽薄??瀹?姹???澶??峰?瀵矽薄??杩??ヨ?琛??舵????

14??Overload??Override???哄????Overloaded???規???????浠ユ?瑰??杩????肩??绫誨???

?規???????Overriding????杞?verloading??Java澶????х??涓???琛ㄧ?般??????Overriding???剁被涓?瀛?绫諱??村????х??涓?绉?琛ㄧ?幫???杞?verloading??涓?涓?绫諱腑澶????х??涓?绉?琛ㄧ?般??濡????ㄥ??绫諱腑瀹?涔????規?涓??剁?剁被???稿??????绉闆?????幫???浠?璇磋?ユ?規?琚????? (Overriding)??瀛?绫葷??瀵矽薄浣跨?ㄨ?涓??規??訛?灏?璋??ㄥ??绫諱腑??瀹?涔?锛?瀵瑰????瑷?锛??剁被涓???瀹?涔?濡???琚?"灞???浜???濡????ㄤ?涓?绫諱腑瀹?涔?浜?澶?涓????????規?锛?瀹?浠?????涓????????頒釜?版????涓????????扮被??锛???绉頒負?規?????杞?Overloading)??Overloaded???規?????浠ユ?瑰??杩????肩??绫誨????

15??error??exception??浠?涔??哄???

error 琛ㄧず?㈠?涓???涓????戒?寰??伴?劇?????典???涓?绉?涓ラ????棰???姣?濡?璇村??瀛?婧㈠?恒??涓????芥????绋?搴??藉???杩??風?????點??

??? exception 琛ㄧず涓?绉?璁捐?℃??瀹??伴??棰???涔?灏辨??璇達?瀹?琛ㄧず濡???绋?搴?杩?琛?姝e父锛?浠?涓?浼??????????點??

16????姝ュ??寮?姝ユ??浣?寮???锛??ㄤ?涔????典?????浣跨?ㄤ?浠?锛?涓句?璇存????

濡????版??灏??ㄧ嚎绋??村?變韓??渚?濡?姝e?ㄥ?????版??浠ュ?????借????涓?绾跨?璇誨?幫?????姝e?ㄨ?葷???版?????藉凡缁?琚????涓?绾跨???杩?浜?锛??d?杩?浜??版??灏辨???變韓?版??锛?蹇?椤昏?琛???姝ュ??????

褰?搴??ㄧ?搴??ㄥ?矽薄涓?璋??ㄤ?涓?涓???瑕??辮垂寰??挎?堕?存?ユ?ц????規?锛?骞朵?涓?甯???璁╃?搴?绛?寰??規???杩????訛?灏卞?璇ヤ嬌?ㄥ?姝ョ?绋?锛??ㄥ?澶????典????ㄥ?姝ラ??寰?寰?寰??存????????

17??abstract class??interface??浠?涔??哄???

澹版???規???瀛??ㄨ??涓??誨???闆????绫昏??????借薄绫夥?abstract class锛?锛?瀹??ㄤ?瑕???寤轟?涓?浣??版??浜??烘??琛?涓虹??绫夥?骞朵負璇ョ被澹版???規?锛?浣?涓??藉?ㄨ?ョ被涓?瀹??拌?ョ被?????點??涓??藉??寤?bstract 绫葷??瀹?渚????惰????浠ュ??寤轟?涓?????锛??剁被????涓?涓??借薄绫夥?骞惰?╁???????蜂?瀛?绫葷??涓?涓?瀹?渚???涓??芥???借薄?????芥?版???借薄?????規???Abstract 绫葷??瀛?绫諱負瀹?浠??剁被涓????????借薄?規???渚?瀹??幫?????瀹?浠?涔????借薄绫諱負??????浠d?锛??ㄥ??绫諱腑瀹??拌?ユ?規????ラ???惰?涓虹???跺??绫誨??浠ュ?ㄧ被涓?瀹??拌?浜??規???

?ュ?o?interface锛????借薄绫葷????浣????ㄦ?ュ?d腑锛??????規??芥???借薄????澶?缁ф?挎?у????杩?瀹??拌??風???ュ?h???峰????ュ?d腑???????規??芥???借薄??锛?娌℃??涓?涓???绋?搴?浣????ュ?e????浠ュ??涔?static final???????????ュ?g??瀹??頒?瀛?绫葷?鎬技锛??や?璇ュ???扮被涓??戒??ュ?e??涔?涓?缁ф?胯?涓恒??褰?绫誨???扮?規???ュ?f?訛?瀹?瀹?涔?锛??沖?绋?搴?浣?缁?浜?锛?????杩?绉??ュ?g???規????跺??锛?瀹???浠ュ?ㄥ???頒?璇ユ?ュ?g??绫葷??浠諱?瀵矽薄涓?璋??ㄦ?ュ?g???規????變????借薄绫夥?瀹???璁鎬嬌?ㄦ?ュ?e??浣?涓哄??ㄥ??????绫誨??????甯哥???ㄦ????缂?灏???????寮??ㄥ??浠ヨ漿?㈠?版?ュ?g被????浠??ュ?g被??杞????instanceof 杩?绠?绗???浠ョ?ㄦ?ュ?沖????瀵矽薄??绫繪???????頒??ュ?c??

18??heap??stack??浠?涔??哄????

????涓?绉?绾垮艦????锛??舵坊???????ゅ??绱?????浣?搴??ㄥ??涓?娈靛???????????у??杩????虹???瑰?杩?琛?澶?????

????????涓?涓?缁?????绱?

19??forward ??redirect???哄??

forward?????″?ㄨ?鋒?璧?婧?锛????″?ㄧ?存?ヨ?塊???????闆????URL锛????d釜URL????搴???瀹矽?誨??杩??ワ??跺????杩?浜???瀹瑰????缁?娴?瑙????娴?瑙??ㄦ?規??涓??ラ?????″?ㄥ????????瀹規??浠????挎?ョ??锛???浠ュ?????闆????涓?杩??????ョ???闆????

??? redirect灏辨?????$???規???昏?,????涓?涓??舵????,??璇?娴?瑙??ㄩ???闆?昏?鋒??d釜?闆??锛?涓????ヨ?存?瑙??ㄤ??ㄥ????璇鋒??????????伴???拌?鋒?锛???浠?ession,request???伴?藉??浠ヨ?峰????

20??EJB涓?JAVA BEAN???哄??锛?

Java Bean ????澶??ㄧ??缁?浠訛?瀵?ava Bean骞舵病??涓ユ?肩??瑙???锛???璁轟?璁詫?浠諱?涓?涓?Java绫婚?藉??浠ユ??涓?涓?Bean??浣???甯告???典?锛??變?Java Bean??琚?瀹瑰?ㄦ????寤猴?濡?Tomcat锛???锛???浠?ava Bean搴??鋒??涓?涓?????????????????锛???甯?ava Bean杩?瑕?瀹???erializable?ュ?g?ㄤ?瀹???ean????涔??с??Java Bean瀹???涓??稿?浜?寰?杞?COM妯″??涓??????拌?绋???COM缁?浠訛?瀹???涓??借?璺ㄨ?绋?璁塊??????Enterprise Java Bean ?稿?浜?DCOM锛??沖??甯?寮?缁?浠躲??瀹????轟?Java??杩?绋??規?璋????RMI锛???????锛???浠?JB??浠ヨ?杩?绋?璁塊??锛?璺ㄨ?绋???璺ㄨ?$???猴???浣?EJB蹇?椤昏?甯?缃插?ㄨ?稿?Webspere??WebLogic杩??風??瀹瑰?ㄤ腑锛?EJB瀹㈡?蜂?涓??存?ヨ?塊????姝g??EJB缁?浠訛???????杩??跺?瑰?ㄨ?塊????EJB瀹瑰?ㄦ??EJB缁?浠剁??浠g??锛?EJB缁?浠剁?卞?瑰?ㄦ????寤哄??绠$????瀹㈡?烽??杩?瀹瑰?ㄦ?ヨ?塊????姝g??EJB缁?浠躲??

21??Static Nested Class ?? Inner Class??涓?????

??? Static Nested Class??琚?澹版??涓洪????锛?static锛??????ㄧ被锛?瀹???浠ヤ?渚?璧?浜?澶??ㄧ被瀹?渚?琚?瀹?渚?????????甯哥?????ㄧ被??瑕??ㄥ??ㄧ被瀹?渚????????藉??渚?????

22??JSP涓??ㄦ??INCLUDE涓?????INCLUDE???哄??锛?

?ㄦ??INCLUDE??sp:include?ㄤ?瀹???<jsp:include page="included.jsp" flush="true" />瀹??繪??浼?妫??ユ??????浠朵腑??????锛??????ㄤ??????ㄦ??椤甸???骞朵???浠ュ甫???般??

????INCLUDE??nclude浼???瀹???瀹?涓?浼?妫??ユ??????浠剁??????锛????ㄤ?????????椤甸??lt;%@ include file="included.htm" %>

23??浠?涔??跺????ssert??

??? assertion(??瑷?)?ㄨ蔣浠跺???涓???涓?绉?甯哥?ㄧ??璋?璇??瑰?锛?寰?澶?寮???璇?瑷?涓??芥????杩?绉??哄?躲???ㄥ???頒腑锛?assertion灏辨???ㄧ?搴?涓???涓??¤???ワ?瀹?瀵逛?涓?boolean琛ㄨ揪寮?杩?琛?妫??ワ?涓?涓?姝g‘绋?搴?蹇?椤諱?璇?杩?涓?boolean琛ㄨ揪寮????間負true锛?濡???璇ュ?間負false锛?璇存??绋?搴?宸茬?澶?浜?涓?姝g‘???舵??涓?锛?绯葷?灏?缁??鴻?????????恒??涓????ヨ?達?assertion?ㄤ?淇?璇?绋?搴????烘?????抽????姝g‘?с??assertion妫??ラ??甯稿?ㄥ?????娴?璇??跺?????涓轟???楂??ц?斤??ㄨ蔣浠跺??甯???锛?assertion妫??ラ??甯告???抽??????

24??GC??浠?涔?? 涓轟?涔?瑕???GC?

????GC?????炬?堕????????锛?Gabage Collection锛?,??瀛?澶?????缂?绋?浜哄??瀹規???虹?伴??棰????版?癸?蹇?璁版??????璇?????瀛????朵?瀵艱?寸?搴???绯葷???涓?绋沖?????沖穿婧?锛?Java??渚???GC???藉??浠ヨ???ㄧ??娴?瀵矽薄?????杩?浣??ㄥ??浠???杈懼?拌???ㄥ???跺??瀛???????锛?Java璇?瑷?娌℃????渚????懼凡??????瀛????劇ず??浣??規???

25??short s1 = 1; s1 = s1 + 1;??浠?涔???? short s1 = 1; s1 += 1;??浠?涔????

??? short s1 = 1; s1 = s1 + 1; 锛?s1+1杩?绠?缁?????int??锛???瑕?寮哄?惰漿?㈢被??锛?

short s1 = 1; s1 += 1;锛???浠ユ?g‘缂?璇?锛?

26??Math.round(11.5)绛??煎?灏?? Math.round(-11.5)绛??煎?灏??

??? Math.round(11.5)==12

Math.round(-11.5)==-11

round?規?杩???涓????版???ヨ????挎?存?幫????闆??1/2??姹???loor.

27??String s = new String("xyz");??寤轟???涓?String Object?

??? 涓や釜

28??璁捐??涓?绾跨?锛??朵腑涓や釜绾跨?姣?娆″??澧???1锛????涓や釜绾跨?瀵?姣?娆″??灏?1?????虹?搴???

浠ヤ?绋?搴?浣跨?ㄥ???ㄧ被瀹??扮嚎绋?锛?瀵?澧??????跺??娌℃??????椤哄???棰???

public class ThreadTest1{

? private int j;

? public static void main(String args[]){

ThreadTest1 tt=new ThreadTest1();

Inc inc=tt.new Inc();

Dec dec=tt.new Dec();

for(int i=0;i<2;i++){

Thread t=new Thread(inc);

t.start();

t=new Thread(dec);

t.start();

}

}

? private synchronized void inc(){

j++;

System.out.println(Thread.currentThread().getName()+"-inc:"+j);

? }

? private synchronized void dec(){

j--;

System.out.println(Thread.currentThread().getName()+"-dec:"+j);

? }

? class Inc implements Runnable{

public void run(){

for(int i=0;i<100;i++){

inc();

}

}

? }

? class Dec implements Runnable{

public void run(){

for(int i=0;i<100;i++){

dec();

}

?}

? }

}

29??Java??娌℃??goto?

java涓???淇???瀛?锛??闆?ㄦ病????ava涓?浣跨?ㄣ??

30?????ㄤ?涓?绾跨?????un()杩???start()?

???ㄤ?涓?绾跨???璋???tart()?規?锛?浣跨嚎绋???浠h〃??????澶????哄?浜???杩?琛??舵??锛?杩????崇??瀹???浠ョ??VM璋?搴?苟?ц???杩?骞朵????崇??绾跨?灏變?绔??寵?琛???run()?規???浠ヤ駭??蹇?椤婚???虹????蹇??ュ??姝??涓?绾跨???

31 ??EJB????锛?SessionBean,EntityBean锛?璇村?轟?浠??????藉?ㄦ??锛???濡?浣?绠$??浜??$??锛?

SessionBean锛?Stateless Session Bean ?????藉?ㄦ?????卞?瑰?ㄥ?沖????锛?褰?瀹㈡?鋒?哄???鴻?鋒?瑕?寤虹??涓?涓?Bean??瀹?渚??訛?EJB瀹瑰?ㄤ?涓?瀹?瑕???寤轟?涓??扮??Bean??瀹?渚?渚?瀹㈡?鋒?鴻??????????渚挎?句?涓??版????瀹?渚???渚?缁?瀹㈡?鋒?恒??褰?瀹㈡?鋒?虹??涓?娆¤??ㄤ?涓?Stateful Session Bean ?訛?瀹瑰?ㄥ?椤葷???沖?ㄦ???″?ㄤ腑??寤轟?涓??扮??Bean瀹?渚?锛?骞跺?寵???闆?㈡?鋒?轟?锛?浠ュ??姝ゅ?㈡?鋒?鴻???tateful Session Bean ???規??跺?瑰?ㄤ???璋??ㄥ??娲懼?頒?姝ゅ?㈡?鋒?虹?稿?寵????Bean瀹?渚???

EntityBean锛?Entity Beans?藉??娲葷?稿?矽??跨???堕?達?骞朵??舵??????缁???????瑕??版??搴?涓????版??瀛????Entity beans灏變??村??娲彙????涓??????у??ㄧ?搴????????¤?绋??ヨ?寸?????充嬌EJB瀹瑰?ㄥ穿婧?浜?锛?Entity beans涔???瀛?娲葷????Entity Beans???藉?ㄦ???藉?琚?瀹瑰?ㄦ???? Beans??宸辯?$????

EJB??杩?浠ヤ?????绠$??瀹??★?瀵矽薄绠$??缁?缁?锛?OMG锛???瀵矽薄瀹??℃???★?OTS锛?锛?Sun Microsystems??Transaction Service锛?JTS锛???Java Transaction API锛?JTA锛?锛?寮???缁?锛?X/Open锛???XA?ュ?c??

32??搴??ㄦ???″?ㄦ???d?锛?

BEA WebLogic Server锛?IBM WebSphere Application Server锛?Oracle9i Application Server锛?jBoss锛?Tomcat

33??缁???涓?涓?浣???甯歌??扮??runtime exception??

ArithmeticException, ArrayStoreException, BufferOverflowException, BufferUnderflowException, CannotRedoException, CannotUndoException, ClassCastException, CMMException, ConcurrentModificationException, DOMException, EmptyStackException, IllegalArgumentException, IllegalMonitorStateException, IllegalPathStateException, IllegalStateException, ImagingOpException, IndexOutOfBoundsException, MissingResourceException, NegativeArraySizeException, NoSuchElementException, NullPointerException, ProfileDataException, ProviderException, RasterFormatException, SecurityException, SystemException, UndeclaredThrowableException, UnmodifiableSetException, UnsupportedOperationException

34???ュ?f??????缁ф?挎?ュ?? ?借薄绫繪??????瀹???implements)?ュ?? ?借薄绫繪??????缁ф?垮??浣?绫?concrete class)?

?ュ?e??浠ョ戶?挎?ュ?c???借薄绫誨??浠ュ????implements)?ュ?o??借薄绫繪??????缁ф?垮??浣?绫夥?浣???????瀹?浣?绫誨?椤繪????纭????????芥?般??

35??List, Set, Map????戶?胯??Collection?ュ??

??? List锛?Set??锛?Map涓???

36??璇村?烘?版??杩??ユ???宸ヤ??哄?舵??浠?涔??

J2EE???″?ㄥ???ㄦ?朵?寤虹??涓?瀹??伴????姹?杩??ワ?骞朵??寸淮??涓?灏?浜?姝ゆ?扮????姹?杩??ャ??瀹㈡?風??绋?搴???瑕?杩??ユ?訛?姹?椹卞?ㄧ?搴?浼?杩???涓?涓???浣跨?ㄧ??姹?杩??ュ苟灏??惰〃璁頒負蹇???濡???褰???娌℃??绌洪?茶??ワ?姹?椹卞?ㄧ?搴?灏辨?闆緩涓?瀹??伴????杩??ワ??闆緩杩??ョ???伴??????缃????闆?沖????褰?浣跨?ㄧ??姹?杩??ヨ??ㄥ??????锛?姹?椹卞?ㄧ?搴?灏?姝よ??ヨ〃璁頒負绌洪?詫??朵?璋??ㄥ氨??浠ヤ嬌?ㄨ?涓?杩??ャ??

37??abstract??method?????????舵??static,?????????舵??native锛??????????舵??synchronized?

??? ?戒???38???扮???娌℃??length()杩?涓??規?? String??娌℃??length()杩?涓??規?锛?

?扮?娌℃??length()杩?涓??規?锛???length??灞??с??String????length()杩?涓??規???

39??Set??????绱???涓??介??澶???锛??d??ㄤ?涔??規??ュ?哄????澶?涓????? ????=杩???equals()? 瀹?浠???浣??哄???

Set??????绱???涓??介??澶???锛??d???terator()?規??ュ?哄????澶?涓?????equals()???よ?諱袱涓?Set?????哥????

??? equals()??==?規??沖??寮??ㄥ?兼??????????涓?瀵矽薄equals()?ㄧ被涓?琚?瑕???锛?涓虹????褰?涓や釜??绂葷??瀵矽薄????瀹瑰??绫誨???擱????璇?锛?杩??????箋??

40????????onstructor??????琚?override?

??????onstructor涓??借?缁ф?匡???姝や??介????Overriding锛?浣???浠ヨ???杞?verloading??

41????????浠ョ戶??tring绫?

String绫繪??final绫繪??涓???浠ョ戶?褲??

42??swtich?????戒??ㄥ??yte涓?锛??????戒??ㄥ??ong涓?锛??????戒??ㄥ??tring涓??

switch锛?expr1锛?涓?锛?expr1??涓?涓??存?拌〃杈懼?????姝や???缁? switch ?? case 璇??ョ?????闆?璇ユ?? int?? short?? char ???? byte??long,string ?戒??戒??ㄤ?swtich??

43??try {}????涓?涓?return璇??ワ??d?绱ц??ㄨ?涓?try????finally {}????code浼?涓?浼?琚??ц?锛?浠?涔??跺??琚??ц?锛???eturn??杩??????

浼??ц?锛???eturn???ц???

44??缂?绋?棰?: ?ㄦ???????????規?绠???涔?浠?绛??煎???

2 << 3

45??涓や釜瀵矽薄?肩?稿??(x.equals(y) == true)锛?浣??村????涓?????hash code锛?杩??ヨ??瀵逛?瀵?

涓?瀵癸????稿????hash code??

46??褰?涓?涓?瀵矽薄琚?褰?浣????頒????頒?涓??規???锛?姝ゆ?規????瑰??杩?涓?瀵矽薄??灞??э?骞跺??杩???????????缁???锛??d?杩????闆????間???杩???寮??ㄤ????

???間?????Java 缂?绋?璇?瑷??????間??????般??褰?涓?涓?瀵矽薄瀹?渚?浣?涓轟?涓????拌?浼????版?規?涓??訛????扮???煎氨??瀵矽?ュ?矽薄??寮??ㄣ??瀵矽薄????瀹瑰??浠ュ?ㄨ?璋??ㄧ???規?涓??瑰??锛?浣?瀵矽薄??寮??ㄦ??姘歌?涓?浼??瑰??????

47??褰?涓?涓?绾跨?杩??ヤ?涓?瀵矽薄??涓?涓?synchronized?規???锛??跺??绾跨???????杩??ユ?ゅ?矽薄???跺???規??

涓??斤?涓?涓?瀵矽薄??涓?涓?synchronized?規????界?變?涓?绾跨?璁塊????

48??缂?绋?棰?: ??涓?涓?Singleton?烘?ャ??

Singleton妯″?涓昏?浣??ㄦ??淇?璇???ava搴??ㄧ?搴?涓?锛?涓?涓?绫?lass????涓?涓?瀹?渚?瀛??ㄣ??

涓???Singleton妯″???甯告????绉?绉?褰㈠?:

绗?涓?绉?褰㈠?: 瀹?涔?涓?涓?绫夥?瀹????????芥?頒負private??锛?瀹???涓?涓?static??private??璇ョ被????锛??ㄧ被??濮????跺??渚?璇?锛???杩?涓?涓?public??getInstance?規??峰??瀵瑰????寮???缁ц??璋??ㄥ?朵腑???規???

public class Singleton {

private Singleton(){}

??????? //?ㄨ??宸卞???ㄥ??涔???宸變?涓?瀹?渚?锛???涓???寰?濂???锛?

??????? //娉ㄦ??杩???private ??渚????ㄨ?????????? private static Singleton instance = new Singleton();

??????? //杩?????渚?浜?涓?涓?渚?澶??ㄨ?塊????class???????規?锛???浠ョ?存?ヨ?塊??????

??????? public static Singleton getInstance() {

??????????? return instance; ????

??????? }

??? }

??? 绗?浜?绉?褰㈠?:

public class Singleton {

????private static Singleton instance = null;

????public static synchronized Singleton getInstance() {

????//杩?涓??規?姣?涓??㈡?????矽?锛?涓??ㄦ??娆¢?借?琛?????瀵矽薄锛?????绗?涓?娆°?????? ??

????//浣跨?ㄦ?剁????瀹?渚?锛???楂?浜?????锛?

????if (instance==null)

????????instance锛?new Singleton();

return instance; ????}

}

?朵?褰㈠?:

瀹?涔?涓?涓?绫夥?瀹????????芥?頒負private??锛??????規?涓?tatic????

涓???璁や負绗?涓?绉?褰㈠?瑕??村??瀹??ㄤ?

49??Java???ュ?e??C++????绫葷???稿????涓???澶???

?變?Java涓?????澶?缁ф?匡????????芥??涓?绫繪??瀵矽薄瑕?浣跨?ㄥ?????ㄥ??涓?绫繪??瀵矽薄???㈢???規???灞??э??版??????缁ф?挎?哄?跺氨涓??芥弧瓒寵?姹???涓?缁ф?跨?告??锛??ュ?f???撮?????墊椿?э???涓烘?ュ?d腑娌℃??浠諱?瀹??頒唬????褰?涓?涓?绫誨???頒??ュ?d互??锛?璇ョ被瑕?瀹??版?ュ?i???㈡???????規???灞??э?骞朵??ュ?i???㈢??灞??у?ㄩ?璁ょ?舵??涓??㈤?芥??public static,?????規?榛?璁ゆ???典???public.涓?涓?绫誨??浠ュ???闆?涓??ュ?c??

50??Java涓???寮?甯稿????哄?剁??绠?????????搴??ㄣ??

褰?JAVA绋?搴?杩???浜?JAVA??璇?涔?瑙????訛?JAVA?????哄氨浼?灏?????????璇?琛ㄧず涓轟?涓?寮?甯搞??杩???璇?涔?瑙???????2绉????點??涓?绉???JAVA绫誨???缃???璇?涔?妫??ャ??渚?濡??扮?涓???瓒???,浼?寮???IndexOutOfBoundsException;璁塊??null??瀵矽薄?朵?寮???NullPointerException?????绉????靛氨??JAVA??璁哥?搴????╁?杩?绉?璇?涔?妫??ワ?绋?搴?????浠ュ??寤鴻??宸辯??寮?甯革?骞惰???遍???╁?ㄤ??剁??hrow?抽??瀛?寮???寮?甯搞????????寮?甯擱?芥??java.lang.Thowable??瀛?绫彙??

51?????懼???剁??浼??瑰????????骞惰????2绉????舵?哄?躲??

Java璇?瑷?涓?涓?涓??捐?????圭?瑰氨??寮??ヤ????懼???舵?哄?訛?浣?++绋?搴?????澶寸?肩????瀛?绠$??????棰?杩?????瑙o?瀹?浣垮?Java绋?搴????ㄧ???绋?搴????跺??涓?????瑕???????瀛?绠$?????變???涓????懼???舵?哄?訛?Java涓???瀵矽薄涓?????"浣??ㄥ??"??姒?蹇碉?????瀵矽薄??寮??ㄦ????"浣??ㄥ??"?????懼???跺??浠ユ???????叉?㈠??瀛?娉??詫???????浣跨?ㄥ??浠ヤ嬌?ㄧ????瀛??????懼???跺?ㄩ??甯告??浣?涓轟?涓???????浣?绾у????绾跨?杩?琛?锛?涓???棰??ョ?????典?瀵瑰??瀛???涓?宸茬?姝諱骸???????挎?堕?存病??浣跨?ㄧ??瀵矽薄杩?琛?娓?妤??????訛?绋?搴???涓??藉???剁??璋??ㄥ???懼???跺?ㄥ?規??涓?瀵矽薄??????瀵矽薄杩?琛????懼???躲?????舵?哄?舵????浠e??跺???懼???跺????璁闆???懼???訛?澧??????懼???躲??

52??璇瘋?村?轟????ラ????绾跨???姝ョ???規???

wait():浣誇?涓?绾跨?澶?浜?绛?寰??舵??锛?骞朵????炬????????瀵矽薄??lock??

sleep():浣誇?涓?姝e?ㄨ?琛???绾跨?澶?浜??$???舵??锛???涓?涓??????規?锛?璋??ㄦ?ゆ?規?瑕?????InterruptedException寮?甯搞??

notify():?ら??涓?涓?澶?浜?绛?寰??舵????绾跨?锛?娉ㄦ???????ㄨ??ㄦ?ゆ?規????跺??锛?骞朵??界‘?????ら????涓?涓?绛?寰??舵????绾跨?锛???????VM纭?瀹??ら????涓?绾跨?锛???涓?涓?????浼???绾с??

Allnotity():?ら??????澶??ョ??寰??舵????绾跨?锛?娉ㄦ??骞朵???缁??????ら??绾跨?涓?涓?瀵矽薄????锛?????璁╁??浠?绔?浜???

53??浣????ラ????????绫婚?芥????浜?锛?涓昏??規?锛?

??甯哥?ㄧ??????绫繪?? List ?? Map?? List ???蜂?瀹??闆???? ArrayList ?? Vector锛?瀹?浠???????澶у?????琛??姣?杈???????寤恒??瀛??ㄥ????浣?浠諱?绫誨??瀵矽薄????绱???琛ㄣ?? List ???ㄤ????闆?肩儲寮?璁塊????绱?????褰???

Map ??渚?浜?涓?涓??撮???ㄧ????绱?瀛??ㄦ?規??? Map ????绫葷?ㄤ?瀛??ㄥ??绱?瀵癸?绉頒?"??"??"??锛?锛??朵腑姣?涓?????灏??頒?涓??箋??

54????杩頒?涓?JVM??杞?lass??浠剁???????哄??

JVM涓?绫葷??瑁?杞芥????lassLoader??瀹???瀛?绫繪?ュ???扮??,Java ClassLoader ??涓?涓???瑕???Java杩?琛??剁郴缁?缁?浠躲??瀹?璐?璐e?ㄨ?琛??舵?ユ?懼??瑁??ョ被??浠剁??绫彙??

55??char??????涓??戒??藉??璐?涓?涓?涓???姹?瀛??涓轟?涔??

?藉?瀹?涔???涓轟?涓?涓?????锛???涓?ava涓?浠?nicode缂???锛?涓?涓?char??16涓?瀛???锛???浠ユ?句?涓?涓?????娌¢??棰???

56??澶?绾跨?????绉?瀹??版?規?,?芥??浠?涔????姝ユ????绉?瀹??版?規?,?芥??浠?涔??

澶?绾跨???涓ょ?瀹??版?規?锛???????缁ф??hread绫諱?瀹???unnable?ュ??

??姝ョ??瀹??版?歸?㈡??涓ょ?锛???????synchronized,wait涓?notify

57??JSP????缃?瀵矽薄???規???

request琛ㄧずHttpServletRequest瀵矽薄??瀹?????浜????蟲?瑙??ㄨ?鋒???淇℃??锛?骞朵???渚?浜???涓??ㄤ??峰??cookie, header, ??session?版???????ㄧ???規???

??? response琛ㄧずHttpServletResponse瀵矽薄锛?骞舵??渚?浜???涓??ㄤ?璁劇疆????娴?瑙??ㄧ????搴????規?锛?濡?cookies,澶翠俊??绛?锛?

??? out瀵矽薄??javax.jsp.JspWriter??涓?涓?瀹?渚?锛?骞舵??渚?浜???涓??規?浣誇??界?ㄤ???娴?瑙??ㄥ????杈??虹?????

??? pageContext琛ㄧず涓?涓?javax.servlet.jsp.PageContext瀵矽薄??瀹????ㄤ??逛究瀛?????绉????寸????瀛?绌洪?淬??servlet?稿?崇??瀵矽薄??API锛?骞朵???瑁?浜????ㄧ??servlet?稿?沖???界???規???

??? session琛ㄧず涓?涓?璇鋒???javax.servlet.http.HttpSession瀵矽薄??Session??浠ュ??璐??ㄦ?風???舵??淇℃??

??? applicaton 琛ㄧず涓?涓?javax.servle.ServletContext瀵矽薄??杩????╀??ユ?炬????ervlet寮?????servlet??澧???淇℃??

??? config琛ㄧず涓?涓?javax.servlet.ServletConfig瀵矽薄??璇ュ?矽薄?ㄤ?瀛???servlet瀹?渚?????濮??????般??

??? page琛ㄧず浠?璇ラ〉??駭????涓?涓?servlet瀹?渚?

58??绾跨????烘??姒?蹇點??绾跨????烘???舵??浠ュ???舵??涔??寸???崇郴

绾跨????ㄧ?搴??ц?杩?绋?涓?锛??藉??ц?绋?搴?浠g????涓?涓??ц???浣?锛?姣?涓?绋?搴??沖??芥??涓?涓?绾跨?锛?涔?灏辨??绋?搴???韬???

Java涓???绾跨?????绉??舵????????锛?杩?琛???灏辯華????璧楓??缁?????

59??JSP??甯哥?ㄦ??浠?<%@page language="java" contenType="text/html;charset=gb2312" session="true" buffer="64kb" autoFlush="true" isThreadSafe="true" info="text" errorPage="error.jsp" isErrorPage="true" isELIgnored="true" pageEncoding="gb2312" import="java.sql.*"%>

isErrorPage(?????戒嬌??xception瀵矽薄)锛?isELIgnored(????拷?ヨ〃杈懼?)

<%@include file="filename"%>

<%@taglib prefix="c"uri="http://......"%>

60??浠?涔????典?璋???oGet()??doPost()锛?

Jsp椤甸??腑??form??绛鵑????method灞??т負get?惰???oGet()锛?涓?ost?惰???oPost()??

61??servlet?????藉?ㄦ??

web瀹瑰?ㄥ??杞?ervlet锛????藉?ㄦ??寮?濮?????杩?璋???ervlet??init()?規?杩?琛?servlet????濮???????杩?璋???ervice()?規?瀹??幫??規??璇鋒???涓???璋??ㄤ?????do***()?規???缁??????★?web瀹瑰?ㄨ???ervlet??destroy()?規???

62??濡?浣??闆??servlet????绾跨?妯″?

<%@ page isThreadSafe="false"%>

63 ??椤甸?㈤?村?矽薄浼??????規?

request 锛?session锛?application锛?cookie绛?

64 ??JSP??Servlet????浜??稿???瑰??涓????癸?浠?浠?涔??寸????绯繪??浠?涔?锛?

JSP ??Servlet???????╁?锛???璐ㄤ???Servlet??绠????瑰?锛??村己璋?搴??ㄧ??澶?琛ㄨ〃杈俱??JSP缂?璇?????"绫?ervlet"??Servlet??JSP??涓昏???涓????瑰?ㄤ?锛?Servlet??搴??ㄩ?昏?????ava??浠朵腑锛?骞朵?瀹??ㄤ?琛ㄧず灞?涓???HTML????绂誨??ャ????JSP?????墊??Java??HTML??浠ョ?????涓?涓??╁???涓?jsp????浠躲??JSP渚ч??浜?瑙??撅?Servlet涓昏??ㄤ??у?堕?昏???

65 ????绉?浼?璇?璺?韪?????

浼?璇?浣??ㄥ??ServletsJSP 椤甸?㈡??杩?page????浠h〃涓?涓?涓?椤甸?㈢?稿?崇??瀵矽薄??灞??с??涓?涓?椤甸?㈢?變?涓?缂?璇?濂界?? Java servlet 绫夥???浠ュ甫??浠諱??? include ??浠わ?浣???娌℃?? include ?ㄤ?锛?琛ㄧず??杩??㈠???? servlet ??????琚?缂?璇??? servlet ?? JSP 椤甸??request????浠h〃涓? Web 瀹㈡?鋒?哄???虹??涓?涓?璇鋒??稿?崇??瀵矽薄??灞??с??涓?涓?璇鋒????借法瓒?澶?涓?椤甸???娑???澶?涓? Web 缁?浠訛??變? forward ??浠ゅ?? include ?ㄤ????崇郴锛?

session????浠h〃涓??ㄤ???涓? Web 瀹㈡?鋒?虹??涓?涓??ㄦ?蜂?楠??稿?崇??瀵矽薄??灞??с??涓?涓? Web 浼?璇???浠ヤ?缁?甯鎬?璺ㄨ?澶?涓?瀹㈡?鋒?鴻?鋒?

application????浠h〃涓??翠釜 Web 搴??ㄧ?搴??稿?崇??瀵矽薄??灞??с??杩?瀹?璐ㄤ???璺ㄨ??翠釜 Web 搴??ㄧ?搴?锛?????澶?涓?椤甸????璇鋒???浼?璇???涓?涓??ㄥ?浣??ㄥ??

66??Request瀵矽薄??涓昏??規?锛?

setAttribute(String name,Object)锛?璁劇疆??瀛?涓?ame??request?????闆??getAttribute(String name)锛?杩?????ame??瀹???灞??у??getAttributeNames()锛?杩???request瀵矽薄????灞??х????瀛?????锛?缁?????涓?涓???涓劇??瀹?渚?

getCookies()锛?杩???瀹㈡?風????????Cookie瀵矽薄锛?缁?????涓?涓?Cookie?扮?

getCharacterEncoding()锛?杩???璇鋒?涓???瀛?绗?????瑰?

getContentLength()锛?杩???璇鋒???Body???垮害

getHeader(String name)锛??峰?HTTP??璁?瀹?涔?????浠跺ご淇℃??

getHeaders(String name)锛?杩?????瀹???瀛???request Header???????鹼?缁?????涓?涓???涓劇??瀹?渚?

getHeaderNames()锛?杩?????浠?equest Header????瀛?锛?缁?????涓?涓???涓劇??瀹?渚?

getInputStream()锛?杩???璇鋒???杈??ユ?锛??ㄤ??峰?璇鋒?涓????版??

getMethod()锛??峰?瀹㈡?風???????″?ㄧ??浼????版?????規?

getParameter(String name)锛??峰?瀹㈡?風??浼???缁????″?ㄧ??????name??瀹??????闆??getParameterNames()锛??峰?瀹㈡?風??浼???缁????″?ㄧ???????????扮????瀛?锛?缁?????涓?涓???涓劇??瀹?渚?

getParameterValues(String name)锛??峰???name??瀹??????扮????????getProtocol()锛??峰??瀹㈡?風???????″?ㄧ??浼????版????渚???????璁???绉?getQueryString()锛??峰??ヨ?㈠??绗?覆

getRequestURI()锛??峰?????鴻?鋒?瀛?绗?覆??瀹㈡?風???闆??

getRemoteAddr()锛??峰??瀹㈡?風????IP?闆??

getRemoteHost()锛??峰??瀹㈡?風??????瀛?

getSession([Boolean create])锛?杩?????璇鋒??稿??ession

getServerName()锛??峰?????″?ㄧ????瀛?

getServletPath()锛??峰??瀹㈡?風????璇鋒?????????浠剁??璺?寰?

getServerPort()锛??峰?????″?ㄧ??绔??e??removeAttribute(String name)锛????よ?鋒?涓???涓?涓?灞???67??J2EE??????杩???骞沖?拌???妗??訛?

??? J2EE??韬???涓?涓?????锛?涓?涓?涓轟?涓???甯?寮?搴??ㄧ??寮?????渚???????骞沖?般??

??? J2EE涔???涓?涓?妗??訛?????JDBC??JNDI??RMI??JMS??EJB??JTA绛???????

68????浠???eb搴??ㄥ???杩?绋?涓?缁?甯擱???拌??烘??绉?缂?????瀛?绗??濡?iso8859-1绛?锛?濡?浣?杈??轟?涓???绉?缂?????瀛?绗?覆锛?

? Public String translate (String str) {

??? String tempStr = "";

??? try {

????? tempStr = new String(str.getBytes("ISO-8859-1"), "GBK");

????? tempStr = tempStr.trim();

??? }

??? catch (Exception e) {

????? System.err.println(e.getMessage());

??? }

??? return tempStr;

? }

69??绠?杩伴?昏???浣?(&,|,^)涓??′歡??浣?(&&,||)???哄????

?哄??涓昏?绛?涓ょ?癸?a.?′歡??浣????芥??浣?甯?灏?????,???昏???浣?涓?浠???浠ユ??浣?甯?灏???,??涓???浠ユ??浣??闆?煎??

b.?昏???浣?涓?浼?浜х????璺?

70??XML??妗e??涔?????绉?褰㈠?锛?瀹?浠?涔??存??浣???璐ㄥ?哄??锛?瑙f??XML??妗f??????绉??瑰?锛?

a: 涓ょ?褰㈠? dtd? schema锛?b: ??璐ㄥ?哄??:schema??韬???xml??锛???浠ヨ?XML瑙f???ㄨВ??(杩?涔???浠?DTD涓???灞?schema???規??????)锛?c:??DOM,SAX,STAX绛?

??? DOM:澶???澶у????浠舵?跺?舵?ц?戒???????甯稿??瀹熾??杩?涓???棰?????OM????缁???????????锛?杩?绉?缁??????ㄧ????瀛?杈?澶?锛???涓?DOM蹇?椤誨?ㄨВ????浠朵??????翠釜??妗h??ュ??瀛?,????瀵?ML?????鴻?塊??

SAX:涓??頒?DOM,SAX??浜?浠堕┍?ㄥ????XML瑙f???瑰???瀹?椤哄?璇誨??XML??浠訛?涓???瑕?涓?娆″?ㄩ?ㄨ?杞芥?翠釜??浠躲??褰????闆????浠跺?澶達???妗g???锛???????绛懼?澶翠???绛劇????訛?瀹?浼?瑙???涓?涓?浜?浠訛??ㄦ?烽??杩??ㄥ?跺??璋?浜?浠朵腑???ュ???浠g???ュ???XML??浠訛?????瀵?ML??椤哄?璁塊??

??? STAX:Streaming API for XML (StAX)

71??绠?杩?ynchronized??java.util.concurrent.locks.Lock??寮???锛?

涓昏??稿???癸?Lock?藉????synchronized??瀹??扮??????????涓昏?涓????癸?Lock??姣?synchronized?寸簿纭???绾跨?璇?涔????村ソ???ц?姐??synchronized浼????ㄩ???鵑??锛???Lock涓?瀹?瑕?姹?绋?搴?????宸ラ???撅?骞朵?蹇?椤誨??inally浠??ヤ腑???俱??

72??EJB??瑙??插??涓?涓?瀵矽薄

涓?涓?瀹??寸???轟?EJB????甯?寮?璁$??缁????卞??涓?瑙??茬???锛?杩???涓?瑙??插??浠ョ?變?????寮???????渚?锛?姣?涓?瑙??叉??浣???宸ヤ?蹇?椤婚?靛驚Sun???告??渚???EJB瑙???锛?浠ヤ?璇?褰兼?や??寸???煎?規?с??杩???涓?瑙??插??????EJB缁?浠跺?????锛?Enterprise Bean Provider锛? ??搴??ㄧ?????锛?Application Assembler锛????ㄧ講??锛?Deployer锛???EJB ???″?ㄦ??渚???锛?EJB Server Provider锛???EJB 瀹瑰?ㄦ??渚???锛?EJB Container Provider锛???绯葷?绠$????锛?System Administrator锛?

涓?涓?瀵矽薄??Remote锛?Local锛??ュ?c??Home锛?LocalHome锛??ュ?o?Bean绫?73??EJB瀹瑰?ㄦ??渚???????涓昏???渚?澹版???ㄦ??绠$????浠g??浜х??????缁??х?$????瀹??ㄣ??浜??$?$????????骞跺??琛?绠$??绛????°??

74??EJB瑙???瑙?瀹?EJB涓?绂?姝㈢????浣?????浜?锛?

??? 1.涓??芥??浣?绾跨???绾跨?API(绾跨?API????绾跨?瀵矽薄???規?濡?notify,wait绛?)锛?2.涓??芥??浣?awt锛?3.涓??藉???版???″?ㄥ???斤?4.涓??藉?歸????灞???瀛???锛?5.涓??戒嬌??O??浣??存?ュ??????浠剁郴缁?锛?6.涓??藉??杞芥???闆?.锛?7.涓??藉?this浣?涓哄??????杩???锛?8.涓??藉驚??璋??ㄣ??

75??remote?ュ?e??home?ュ?d富瑕?浣???remote?ュ?e??涔?浜?涓??℃?規?锛??ㄤ?EJB瀹㈡?風??璋??ㄤ??℃?規???

home?ュ?f??EJB宸ュ???ㄤ???寤哄??绉婚?ゆ?ユ??JB瀹?渚?

76??bean 瀹?渚??????藉?ㄦ??

瀵逛?Stateless Session Bean??Entity Bean??Message Driven Bean涓???瀛??ㄧ??叉?绠$??锛???瀵逛?Entity Bean??Statefull Session Bean瀛???ache绠$??锛???甯稿??????寤哄??渚?锛?璁劇疆涓?涓???????寤?JB Object锛?create锛???涓??℃?規?璋??ㄣ??remove绛?杩?绋?锛?瀵逛?瀛??ㄧ??叉?绠$????Bean锛???reate涔???瀹?渚?骞朵?浠???瀛?娓??わ????????ㄧ??叉?璋?搴??哄?朵??????ㄥ??渚?锛???瀵逛?瀛???ache绠$????Bean????杩?婵?娲誨???繪?娲繪?哄?朵???Bean???舵??骞堕???跺??瀛?涓?瀹?渚??伴????

77??EJB??婵?娲繪?哄??浠?tateful Session Bean 涓轟?锛???ache澶у??沖??浜???瀛?涓???浠ュ???跺???ㄧ??Bean瀹?渚????伴??锛??規??MRU??NRU绠?娉?锛?瀹?渚??ㄦ?娲誨???繪?娲葷?舵??涔??磋?绉夥?婵?娲繪?哄?舵??褰?瀹㈡?風??璋??ㄦ??涓?EJB瀹?渚?涓??℃?規??訛?濡???瀵瑰?EJB Object???拌??宸辨病??缁?瀹?瀵瑰???Bean瀹?渚???浠??跺?繪?娲?ean瀛??ㄤ腑锛???杩?搴??????哄?跺???ㄥ??渚?锛???澶?锛?婵?娲夥?姝ゅ??渚????舵????杩???浼?璋??ㄥ?瑰???ejbActive??ejbPassivate?規???

78??EJB????绉?绫誨??

浼?璇?锛?Session锛?Bean 锛?瀹?浣?锛?Entity锛?Bean 娑???椹卞?ㄧ??锛?Message Driven锛?Bean

浼?璇?Bean??????涓烘???舵??锛?Stateful锛??????舵??锛?Stateless锛?涓ょ?

瀹?浣?Bean????涓?ean绠$??????缁??э?BMP锛???瀹瑰?ㄧ?$??????缁??э?CMP锛?涓ょ?

79??瀹㈡??绔?璋???JB瀵矽薄????涓??烘??姝ラ??璁劇疆JNDI???″伐??浠ュ??JNDI???″?闆??绯葷?灞??э??ユ??ome?ュ?o?浠?Home?ュ?h???reate?規???寤?emote?ュ?o???杩?Remote?ュ?h??ㄥ?朵??℃?規???

80??濡?浣?缁?weblogic??瀹?澶у?????瀛??

?ㄥ????eblogic??????涓?锛?浣?浜?????omian瀵瑰????″?ㄧ??褰?涓???startServerName锛?锛?澧???set MEM_ARGS=-Xms32m -Xmx200m锛???浠ヨ??存??灏???瀛?涓?2M锛???澶?00M

81??濡?浣?璁懼????weblogic???????ㄦā寮?(寮???妯″?)涓?浜у????甯?妯″??

??浠ュ?ㄧ?$???у?跺?頒腑淇??瑰?瑰????″?ㄧ?????ㄦā寮?涓哄?????浜у??妯″?涔?涓???????淇??規???$?????ㄦ??浠舵????commenv??浠訛?澧???set PRODUCTION_MODE=true??

82??濡?浣????ㄦ?朵???杈??ョ?ㄦ?峰??涓?瀵????

淇??規???″???ㄦ??浠訛?澧??? WLS_USER??WLS_PW椤廣??涔???浠ュ??oot.properties??浠朵腑澧?????瀵?杩????ㄦ?峰????瀵???.

83????eblogic绠$???跺?頒腑瀵逛?涓?搴??ㄥ??(????璇存??涓?涓?缃?绔?,Domain)杩?琛?jms??ejb??杩??ユ?绛??稿?充俊??杩?琛???缃???,瀹???淇?瀛??ㄤ?涔???浠朵腑?

淇?瀛??ㄦ??omain??config.xml??浠朵腑锛?瀹??????″?ㄧ???稿???缃???浠躲??

84??璇磋??eblogic涓?涓?涓?Domain??缂虹????褰?缁????姣?濡?瑕?灏?涓?涓?绠?????helloWorld.jsp?懼?ヤ???褰?涓?,?剁???ㄦ?瑙??ㄤ?灏卞??????ttp://涓繪??绔??e??/helloword.jsp灏卞??浠ョ???拌?琛?缁???浜?? ??姣?濡?杩??朵腑?ㄥ?頒?涓?涓???宸卞????javaBean璇ュ?浣????

Domain??褰?/???″?ㄧ??褰?/applications锛?灏?搴??ㄧ??褰??懼?ㄦ?ょ??褰?涓?灏???浠ヤ?涓哄??ㄨ?塊??锛?濡?????Web搴????搴??ㄧ??褰???瑕?婊¤凍Web搴??ㄧ??褰?瑕?姹?锛?jsp??浠跺??浠ョ?存?ユ?懼?ㄥ??ㄧ??褰?涓?锛?Javabean??瑕??懼?ㄥ??ㄧ??褰???WEB-INF??褰???classes??褰?涓?锛?璁劇疆???″?ㄧ??缂虹??搴??ㄥ???浠ュ???闆?ㄦ?瑙??ㄤ?????杈??ュ??ㄥ????

85????eblogic涓???甯?ejb??娑????闆??浜???缃???浠?涓???绫誨????EJB娑???????缃???浠朵???锛??芥????扮????缃???浠跺????ejb-jar.xml,weblogic-ejb-jar.xmlCMP瀹?浣?Bean涓???杩???瑕?weblogic-cmp-rdbms-jar.xml

86??濡?浣???eblogic涓?杩?琛?ssl??缃?涓?瀹㈡?風????璁よ????缃???璇磋??2ee(????)杩?琛?ssl????缃?

缂虹??瀹?瑁?涓?浣跨??emoIdentity.jks??DemoTrust.jks? KeyStore瀹???SL锛???瑕???缃????″?ㄤ嬌??nable SSL锛???缃??剁???o??ㄤ駭??妯″?涓???瑕?浠?CA?峰??绉???瀵??ュ???闆??璇?涔????寤?dentity??trust keystore锛?瑁?杞借?峰???瀵??ュ???闆??璇?涔?????浠ラ??缃?姝?SL杩??ユ??????杩???????????

87??濡?浣??ョ????eblogic涓?宸茬???甯???EJB?

??浠ヤ嬌?ㄧ?$???у?跺?幫??ㄥ????Deployment涓???浠ユ?ョ??????宸插??甯???EJB

88??CORBA??浠?涔???ㄩ????浠?涔??

CORBA ?????????卞?矽薄璇鋒?浠g??缁???(Common Object Request Broker Architecture)锛??卞?矽薄绠$??缁?缁? (Object Management Group锛?缂╁??涓?OMG)????????瀹???缁??????ュ?e??涔?璇?瑷?(IDL), 璇?瑷?缁?瀹?(binding:涔?璇?涓鴻??缂?)????璁稿??ㄧ?搴??翠???浣?????璁??? ?剁????涓猴??ㄤ?????绋?搴?璁捐?¤??瑷?涔????ㄤ?????杩?绋?涓?杩?琛?锛?涓轟???????浣?绯葷?寮?????

89??璇磋?翠???????????璇磋???j2ee涓?????绉?甯哥?ㄦā寮????瀵矽?捐?℃ā寮???涓?浜???娉?

? Session Facade Pattern锛?浣跨??essionBean璁塊??EntityBean

Message Facade Pattern锛?瀹??闆?姝ヨ???EJB Command Pattern锛?浣跨??ommand JavaBeans??浠?essionBean锛?瀹??拌交??绾ц?塊??

Data Transfer Object Factory锛???杩?DTO Factory绠???EntityBean?版????渚??規??Generic Attribute Access锛???杩?AttibuteAccess?ュ?g????EntityBean?版????渚??規??Business Interface锛???杩?杩?绋?锛????幫??ュ?e??Bean绫誨???扮?稿???ュ?h???涓??¢?昏?涓??存??锛ワ吉锛㈡?舵????璁捐?″ソ??灏??存?ュ獎??绯葷????ц?姐?????╁??с????缁存?ゆ?с??缁?浠跺?????ㄦ?у??寮?????????椤圭??瓒?澶???锛?椤圭????浼?瓒?搴?澶у??瓒??戒??拌??濂借?捐?$????瑕??с??

90??璇磋?村??eblogic涓?寮???娑???Bean?剁??persistent涓?non-persisten??宸???

persistent?瑰???MDB??浠ヤ?璇?娑???浼???????????涔?灏辨??濡???EJB瀹瑰?ㄥ?虹?伴??棰???JMS???″?ㄤ??朵?灏?娑????ㄦ??DB???ㄧ???跺??????杩??ワ???non锛?persistent?瑰???娑???灏?琚?涓㈠???

91??Servlet?ц??朵???瀹??闆????涓??規?锛?

public void init(ServletConfig config)

public ServletConfig getServletConfig()

public String getServletInfo()

public void service(ServletRequest request,ServletResponse response)

public void destroy()

92??j2ee甯哥?ㄧ??璁捐?℃ā寮?锛?璇存??宸ュ??妯″???

??? Java涓???23绉?璁捐?℃ā寮?锛?

Factory锛?宸ュ??妯″?锛?锛?????? Builder锛?寤洪??妯″?锛?锛??????? Factory Method锛?宸ュ???規?妯″?锛?锛?

Prototype锛???濮?妯″??妯″?锛?锛?Singleton锛???渚?妯″?锛?锛???? Facade锛??ㄩ?㈡ā寮?锛?锛?

Adapter锛??????ㄦā寮?锛?锛???? Bridge锛?妗ユ?妯″?锛?锛???????? Composite锛?????妯″?锛?锛?

Decorator锛?瑁?楗版ā寮?锛?锛???? Flyweight锛?浜???妯″?锛?锛????? Proxy锛?浠g??妯″?锛?锛?

Command锛??戒護妯″?锛?锛?????? Interpreter锛?瑙i???ㄦā寮?锛?锛? Visitor锛?璁塊????妯″?锛?锛?

Iterator锛?杩?浠e??妯″?锛?锛??? Mediator锛?璋?????妯″?锛?锛???? Memento锛?澶?蹇?褰?妯″?锛?锛?

Observer锛?瑙?瀵???妯″?锛?锛??? State锛??舵??妯″?锛?锛????????? Strategy锛?绛??ユā寮?锛?锛?

Template Method锛?妯℃?挎?規?妯″?锛?锛? Chain Of Responsibleity锛?璐d換?炬ā寮?锛?

宸ュ??妯″?锛?宸ュ??妯″???涓?绉?缁?甯歌?浣跨?ㄥ?扮??妯″?锛??規??宸ュ??妯″?瀹??扮??绫誨??浠ユ?規????渚????版??????涓?缁?绫諱腑??涓?涓?绫葷??瀹?渚?锛???甯歌?涓?缁?绫繪??涓?涓????辯???借薄?剁被骞朵?瀹??頒??稿?????規?锛?浣???杩?浜??規???瀵逛??????版??杩?琛?浜?涓???????浣???棣?????瑕?瀹?涔?涓?涓??虹被锛?璇ョ被??瀛?绫婚??杩?涓??????規?瀹??頒??虹被涓????規????跺????瑕?瀹?涔?涓?涓?宸ュ??绫夥?宸ュ??绫誨??浠ユ?規???′歡????涓?????瀛?绫誨??渚???褰?寰??闆??绫葷??瀹?渚???锛?寮???浜哄????浠ヨ??ㄥ?虹被涓????規???涓?蹇??????闆?杩?????????涓?涓?瀛?绫葷??瀹?渚???

93??EJB???存?ュ???闆????涓??℃?ュ?f??Home?ュ?e??锛?璇風??杩扮???便??

杩?绋??ュ?e??Home?ュ?d???瑕??存?ュ???幫?浠?浠???瀹??頒唬?????辨???″?ㄤ駭????锛?绋?搴?杩?琛?涓?瀵瑰?瀹??扮被浼?浣?涓哄?瑰??ュ?g被????瀹?渚?琚?浣跨?ㄣ??

94????搴??芥??????绉??規?锛?璇峰??涓俱????AVA瀹??頒?涓?蹇?????搴???

??? ??搴????規???锛????ユ??搴?锛??存?ユ???ユ??搴???甯?灏???搴?锛?锛?浜ゆ?㈡??搴?锛???娉℃??搴???蹇?????搴?锛?锛????╂??搴?锛??存?ラ???╂??搴???????搴?锛?锛?褰?骞舵??搴?锛???????搴?锛?绠辨??搴????烘?版??搴?锛?

蹇?????搴???浼?浠g????

/ /浣跨?ㄥ揩????搴??規?瀵?[ 0 :n- 1 ]??搴?

浠?a[ 0 :n- 1 ]涓????╀?涓???绱?浣?涓? i d d l e锛?璇ュ??绱?涓烘??????浣?涓?????绱????蹭負涓ゆ??eft ??r i g h t锛?浣垮?l e f t涓?????绱??藉?浜?绛?浜????癸???right 涓?????绱??藉ぇ浜?绛?浜???????褰??頒嬌?ㄥ揩????搴??規?瀵?eft 杩?琛???搴?

??褰??頒嬌?ㄥ揩????搴??規?瀵?ight 杩?琛???搴?

??寰?缁???涓? e f t + m i d d l e + r i g h t

95??璇峰?逛互涓???2EE涓?甯哥?ㄧ????璇?杩?琛?瑙i??(??绠?????杩?

web瀹瑰???缁?澶?浜??朵腑??搴??ㄧ?搴?缁?浠訛?JSP锛?SERVLET锛???渚?涓?涓???澧?锛?浣?SP,SERVLET?存?ユ?村?瑰?ㄤ腑????澧??????ュ?d氦浜?锛?涓?蹇??蟲敞?跺??绯葷???棰???涓昏???WEB???″?ㄦ?ュ???般??渚?濡?锛?TOMCAT,WEBLOGIC,WEBSPHERE绛???璇ュ?瑰?ㄦ??渚????ュ?d弗?奸?靛??J2EE瑙???涓???WEB APPLICATION ????????浠????靛??浠ヤ???????WEB???″?ㄥ氨????J2EE涓???WEB瀹瑰?ㄣ??

EJB瀹瑰???Enterprise java bean 瀹瑰?ㄣ???村?鋒??琛?涓?棰????矽?層??浠???渚?缁?杩?琛??ㄥ?朵腑??缁?浠?JB??绉?绠$?????姐????瑕?婊¤凍J2EE瑙?????EJB?懼?ヨ?ュ?瑰???椹?涓?灏變?琚?瀹瑰?ㄨ?琛?楂???????绠$????骞朵???浠ラ??杩??版?????ュ?f?ヨ?峰?绯葷?绾у???????°??渚?濡???浠舵???°??浜??$?$????

JNDI锛?锛?Java Naming & Directory Interface锛?JAVA?藉????褰????°??涓昏???渚??????芥??锛???渚?涓?涓???褰?绯葷?锛?璁╁?跺?????扮??搴??ㄧ?搴??ㄥ?朵??㈢??涓???宸辯??绱㈠?锛?浠???婊¤凍蹇????ユ?懼??瀹?浣???甯?寮?搴??ㄧ?搴??????姐??

JMS锛?锛?Java Message Service锛?JAVA娑??????°??涓昏?瀹??闆??涓?搴??ㄧ?搴?涔??寸????璁????????瑰?圭?瑰??骞挎????

JTA锛?锛?Java Transaction API锛?JAVA浜??℃???°????渚???绉???甯?寮?浜??℃???°??搴??ㄧ?搴?????璋??ㄥ?舵??渚????ュ?e?沖????

JAF锛?锛?Java Action FrameWork锛?JAVA瀹??ㄨ?よ??妗??躲????渚?涓?浜?瀹??ㄦ?у?舵?歸?㈢??妗??躲??璁╁???????杩???绉??ㄧ講????瀹?涔?瀹??拌??宸辯??涓??у???ㄦ?у?剁???ャ??

RMI/IIOP:锛?Remote Method Invocation /internet瀵矽薄璇鋒?涓?浠???璁?锛?浠?浠?涓昏??ㄤ???杩?杩?绋?璋??ㄦ???°??渚?濡?锛?杩?绋???涓??拌?$???轟?杩?琛?涓?涓?绋?搴?锛?瀹???渚??$エ???????★???浠???浠ュ?ㄦ???拌?$???轟?瀹??闆?瑰?剁?存?ヨ??ㄣ??褰??惰???瑕???杩?涓?瀹???瑙??????藉?ㄥ?????绯葷?涔??磋?琛???淇°??RMI??JAVA?規??????

96??JAVA璇?瑷?濡?浣?杩?琛?寮?甯稿???锛??抽??瀛?锛?throws,throw,try,catch,finally????浠h〃浠?涔???涔?锛???ry??涓???浠ユ???哄?甯稿??锛?

Java??杩??㈠??瀵矽薄???規?杩?琛?寮?甯稿???锛?????绉?涓?????寮?甯歌?琛???绫夥?骞舵??渚?浜???濂界???ュ?c????ava涓?锛?姣?涓?寮?甯擱?芥??涓?涓?瀵矽薄锛?瀹???Throwable绫繪???跺??瀛?绫葷??瀹?渚???褰?涓?涓??規??虹?闆?甯稿??渚挎???轟?涓?寮?甯稿?矽薄锛?璇ュ?矽薄涓???????寮?甯鎬俊??锛?璋??ㄨ?涓?瀵矽薄???規???浠ユ???峰?拌?涓?寮?甯稿苟杩?琛?澶?????Java??寮?甯稿???????杩?5涓??抽??璇??ュ???扮??锛?try??catch??throw??throws??finally??涓??????典?????ry?ユ?ц?涓?娈電?搴?锛?濡????虹?闆?甯革?绯葷?浼????猴?throws锛?涓?涓?寮?甯革?杩??跺??浣???浠ラ??杩?瀹???绫誨???ユ????锛?catch锛?瀹?锛???????锛?finally锛??辯己??澶????ㄦ?ュ?????

??ry?ユ??瀹?涓???棰??叉????"寮?甯???绋?搴???绱ц???ry绋?搴??????搴?????涓?涓?catch瀛??ユ?ユ??瀹?浣??寵???????"寮?甯???绫誨????

throw璇??ョ?ㄦ?ユ??纭??版???轟?涓?"寮?甯???

throws?ㄦ?ユ????涓?涓??????芥?闆???芥???虹????绉?"寮?甯???

Finally涓虹‘淇?涓?娈典唬??涓?绠″????浠?涔?"寮?甯??借??ц?涓?娈典唬????

??浠ュ?ㄤ?涓??????芥?拌??ㄧ??澶??㈠??涓?涓?try璇??ワ??ㄨ?涓??????芥?闆???ㄥ?????涓?try璇??ヤ??ゅ?朵?浠g????姣?褰????頒?涓?try璇??ワ?"寮?甯???妗??跺氨?懼?闆????涓?????村?版??????try璇??ラ?藉??????濡???涓?涓?绾х??try璇??ユ病??瀵規??绉?"寮?甯?杩?琛?澶???锛?????灏變?灞?寮?锛??村?伴???版??澶???杩?绉?"寮?甯???try璇??ャ??

97??涓?涓?".java"婧???浠朵腑??????浠ュ????澶?涓?绫夥?涓??????ㄧ被锛?锛???浠?涔????訛?

??浠ャ??蹇?椤誨????涓?涓?绫誨??涓???浠跺???稿????

98??MVC????涓??ㄥ???芥???d??????ュ????濡?浣?瀹???

MVC??Model锛?View锛?Controller??绠?????"Model" 浠h〃????搴??ㄧ??涓??¢?昏?锛???杩?JavaBean锛?EJB缁?浠跺???幫?锛? "View" ??搴??ㄧ??琛ㄧず?????SP椤甸??駭??锛?锛?"Controller" ????渚?搴??ㄧ??澶???杩?绋??у?訛?涓?????涓?涓?Servlet锛?锛???杩?杩?绉?璁捐?℃ā????搴??ㄩ?昏?锛?澶???杩?绋????劇ず?昏?????涓?????缁?浠跺???般??杩?浜?缁?浠跺??浠ヨ?琛?浜や??????ㄣ??

99??java涓?????绉??規???浠ュ???頒?涓?绾跨?锛??ㄤ?涔??抽??瀛?淇?楗闆??姝ユ?規?? stop()??suspend()?規?涓轟?涓??ㄨ??浣跨???

??涓ょ?瀹??版?規?锛???????缁ф??hread绫諱?瀹???unnable?ュ????ynchronized?抽??瀛?淇?楗闆??姝ユ?規?

??瀵逛嬌??top()锛?????涓哄??涓?瀹??ㄣ??瀹?浼?瑙i?ょ?辯嚎绋??峰??????????瀹?锛???涓?濡???瀵矽薄澶?浜?涓?绉?涓?杩?璐??舵??锛??d??朵?绾跨??藉?ㄩ?g??舵??涓?妫??ュ??淇??瑰??浠???缁???寰??炬??ュ?虹??姝g????棰????ㄣ??suspend()?規?瀹規??????姝婚????璋???uspend()???跺??锛?????绾跨?浼???涓??ワ?浣??翠??舵?????ㄨ?涔????峰?????瀹???姝ゆ?訛??朵?浠諱?绾跨??戒??借?塊????瀹???璧?婧?锛??ら??琚?"??璧???绾跨??㈠?杩?琛???瀵逛換浣?绾跨??ヨ?達?濡???瀹?浠??蟲?㈠?????绾跨?锛????跺??璇??句嬌?ㄤ換浣?涓?涓???瀹???璧?婧?锛?灏變?????姝婚??????浠ヤ?搴?璇ヤ嬌??uspend()锛???搴??ㄨ??宸辯??Thread绫諱腑缃??ヤ?涓???蹇?锛????虹嚎绋?搴?璇ユ椿?ㄨ?????璧楓???ユ??蹇????虹嚎绋?搴?璇ユ??璧鳳?渚跨??ait()?藉?惰??ョ??寰??舵?????ユ??蹇????虹嚎绋?搴?褰??㈠?锛????ㄤ?涓?notify()???闆???ㄧ嚎绋???

100??java涓?????绉?绫誨????娴?锛?JDK涓烘??绉?绫誨????娴???渚?浜?涓?浜??借薄绫諱互渚?缁ф?匡?璇瘋?村?轟?浠?????????浜?绫夥?

瀛???娴?锛?瀛?绗????瀛???娴?缁ф?誇?InputStream / OutputStream锛?瀛?绗??缁ф?誇?InputStreamReader / OutputStreamWriter????ava.io??涓?杩???璁稿??朵???娴?锛?涓昏???涓轟???楂??ц?藉??浣跨?ㄦ?逛究??

101??java涓?浼?瀛??ㄥ??瀛?娉?婕???锛?璇風??????杩般??

浼???濡?锛?int i,i2;? return (i-i2);?? //when i涓鴻凍澶?澶х??姝f??i2涓鴻凍澶?澶х??璐??般??缁???浼?????婧??锛?瀵艱?撮??璇???

102??java涓?瀹??闆??????哄?舵??浠?涔?锛?

?規???????Overriding????杞?verloading??Java澶????х??涓???琛ㄧ?般??????Overriding???剁被涓?瀛?绫諱??村????х??涓?绉?琛ㄧ?幫???杞?verloading??涓?涓?绫諱腑澶????х??涓?绉?琛ㄧ?般??

103?????懼???跺?ㄧ???烘????????浠?涔?锛????懼???跺?ㄥ??浠ラ┈涓????跺??瀛???锛???浠?涔???娉?涓誨?ㄩ???ヨ?????鴻?琛????懼???訛?

瀵逛?GC?ヨ?達?褰?绋?搴?????寤哄?矽薄?訛?GC灏卞?濮????ц?涓?瀵矽薄???闆????澶у?浠ュ??浣跨?ㄦ???點????甯革?GC???ㄦ?????劇???瑰?璁闆???绠$????(heap)涓???????瀵矽薄????杩?杩?绉??瑰?纭?瀹???浜?瀵矽薄??"??杈劇??"锛???浜?瀵矽薄??"涓???杈劇??"??褰?GC纭?瀹?涓?浜?瀵矽薄涓?涓???杈??訛?GC灏辨??璐d換???惰?浜???瀛?绌洪?淬????浠ャ??绋?搴?????浠ユ???ㄦ?ц?System.gc()锛?????C杩?琛?锛?浣???Java璇?瑷?瑙???骞朵?淇?璇?GC涓?瀹?浼??ц???

104????????????瀹?渚????????哄??锛?

static i = 10; //甯擱??

?? class A a;? a.i =10;//????

105??浠?涔???java搴?????锛?濡?浣?瀹???ava搴?????锛?

搴?????灏辨??涓?绉??ㄦ?ュ???瀵矽薄娴????哄?訛???璋?瀵矽薄娴?涔?灏辨??灏?瀵矽薄????瀹矽?琛?娴???????浠ュ?規???????瀵矽薄杩?琛?璇誨????浣?锛?涔???灏?娴???????瀵矽薄浼?杈?浜?缃?缁?涔??淬??搴???????涓轟?瑙e?沖?ㄥ?瑰?矽薄娴?杩?琛?璇誨????浣??舵??寮???????棰???

搴???????瀹??幫?灏???瑕?琚?搴???????绫誨????erializable?ュ?o?璇ユ?ュ?f病????瑕?瀹??扮???規?锛?implements Serializable????涓轟???娉ㄨ?ュ?矽薄????琚?搴???????锛??跺??浣跨?ㄤ?涓?杈??烘?(濡?锛?FileOutputStream)?ユ????涓?涓?ObjectOutputStream(瀵矽薄娴?)瀵矽薄锛??ョ??锛?浣跨??bjectOutputStream瀵矽薄??writeObject(Object obj)?規?灏卞??浠ュ????頒負obj??瀵矽薄?????充?瀛??剁?舵??)锛?瑕??㈠???璇????ㄨ??ユ???

106????????浠ヤ?涓?涓?static?規????ㄥ???哄?歸??static?規???璋????

涓???浠?濡????朵腑????瀵矽薄??method()锛?涓??戒?璇?瀵矽薄??濮???.

107????clone()?規??訛???甯擱?芥??涓?琛?浠g??锛???浠?涔?锛?

Clone ??缂虹??琛?涓猴?super.clone();浠?璐?璐d駭??姝g‘澶у???绌洪?達?骞堕??浣?澶??躲??

108????AVA涓?锛?濡?浣?璺沖?哄?????澶???宓?濂?寰???锛?

??reak; return ?規???

109??List??Map??Set涓?涓??ュ?o?瀛?????绱??訛?????浠?涔??圭?癸?

List 浠ョ?瑰??娆″??ユ??????绱?锛???????澶???绱???Set ??娉??ユ????澶???绱?,???ㄦ??搴???Map 淇?瀛?key-value?鹼?value??澶??箋??

110??J2EE??浠?涔?锛?

J2EE??Sun???告???虹??澶?灞?(multi-diered),??甯?寮?(distributed),?轟?缁?浠?component-base)??浼?涓?绾у??ㄦā??(enterpriese application model).?ㄨ??風??涓?涓?搴??ㄧ郴缁?涓?锛??????у???藉????涓轟?????缁?浠訛?杩?浜?缁?浠跺?????ㄤ???璁$???轟?锛?骞朵?澶?浜??稿???灞?娆?tier)涓?????灞?灞?娆″????瀹㈡?峰?(clietn tier)缁?浠?web灞???缁?浠?Business灞???缁?浠?浼?涓?淇℃??绯葷?(EIS)灞???

111??UML?歸??

????寤烘ā璇?瑷?UML???ㄤ?????????????绫誨?俱??瀵矽薄?懼??????,琛?涓哄??浜や???椤哄?????浣???,瀹??闆?俱??

112??璇村?轟?浜?甯哥?ㄧ??绫夥???锛??ュ?o?璇峰??涓?涓?

甯哥?ㄧ??绫夥?BufferedReader? BufferedWriter? FileReader? FileWirter? String? Integer

甯哥?ㄧ????锛?java.lang? java.awt? java.io? java.util? java.sql

甯哥?ㄧ???ュ?o?Remote? List? Map? Document? NodeList

113??寮???涓??界?ㄥ?頒??d?璁捐?℃ā寮???ㄥ?ㄤ?涔??哄???

姣?涓?妯″??芥??杩頒?涓?涓??ㄦ??浠?????澧?涓?涓????虹?扮????棰?锛??跺????杩頒?璇ラ??棰???瑙e?蟲?規????稿?????杩?杩?绉??瑰?锛?浣???浠ユ???版?″?頒嬌?ㄩ?d?宸叉????瑙e?蟲?規?锛??????ㄩ??澶??稿????宸ヤ???涓昏??ㄥ?頒?MVC??璁捐?℃ā寮????ㄦ?ュ???JSP/Servlet????J2EE???稿?沖??ㄣ??绠???宸ュ??妯″?绛???

114??jsp????浜??ㄤ??浣??ㄥ??????浠?涔??

JSP?辨??浠ヤ?6绉??烘???ㄤ? jsp:include锛??ㄩ〉?㈣?璇鋒????跺??寮??ヤ?涓???浠躲?? jsp:useBean锛?瀵繪?炬????瀹?渚???涓?涓?JavaBean?? jsp:setProperty锛?璁劇疆JavaBean??灞??с?? jsp:getProperty锛?杈??烘??涓?JavaBean??灞??с?? jsp:forward锛???璇鋒?杞??頒?涓??扮??椤甸???? jsp:plugin锛??規??娴?瑙??ㄧ被??涓?ava??浠剁????OBJECT??EMBED??璁般??

115??Anonymous Inner Class (?垮?????ㄧ被) ??????浠?xtends(缁ф???跺??绫夥???????浠?mplements(瀹???interface(?ュ???

??浠ョ戶?垮?朵?绫繪??瀹????朵??ュ?o???wing缂?绋?涓?甯哥?ㄦ?ゆ?瑰???

116??搴??ㄦ???″?ㄤ?WEB SERVER???哄??锛?

搴??ㄦ???″???Weblogic??Tomcat??Jboss

WEB SERVER锛?IIS?? Apache

117??BS涓?CS????绯諱??哄????

C/S??Client/Server??缂╁???????″?ㄩ??甯擱???ㄩ???ц?界??PC??宸ヤ?绔???灏????猴?骞堕???ㄥぇ???版??搴?绯葷?锛?濡?Oracle??Sybase??Informix?? SQL Server??瀹㈡?風????瑕?瀹?瑁?涓??ㄧ??瀹㈡?風??杞?浠躲??

B/锛蟲??Brower/Server??缂╁??锛?瀹㈡?鋒?轟???瑕?瀹?瑁?涓?涓?娴?瑙????Browser锛?锛?濡?Netscape Navigator??Internet Explorer锛????″?ㄥ??瑁?Oracle??Sybase??Informix?? SQL Server绛??版??搴????ㄨ?绉?缁???涓?锛??ㄦ?風???㈠???ㄩ??杩?WWW娴?瑙??ㄥ???幫?涓??ㄥ??浜??¢?昏??ㄥ??绔?瀹??幫?浣???涓昏?浜??¢?昏??ㄦ???″?ㄧ??瀹??般??娴?瑙??ㄩ??杩?锛?b Server ???版??搴?杩?琛??版??浜や???

C/S 涓? B/S ?哄??锛?

锛?锛?纭?浠剁??澧?涓???:

????C/S 涓???寤虹???ㄤ??ㄧ??缃?缁?涓?, 灏????撮????缃?缁???澧?, 灞???缃?涔??村????杩?涓??ㄦ???″?ㄦ??渚?杩??ュ???版??浜ゆ?㈡????

????B/S 寤虹???ㄥ箍??缃?涔?涓???, 涓?蹇???涓??ㄧ??缃?缁?纭?浠剁??澧?,渚?涓??佃??涓?缃?, 绉??ㄨ?懼?. 淇℃????宸辯?$??. ??姣?C/S?村己????搴????? 涓?????瑕?????浣?绯葷???娴?瑙??ㄥ氨琛?

锛?锛?瀵瑰???ㄨ?姹?涓???

????C/S 涓????㈠???稿?瑰?哄?????ㄦ?風兢, 瀵逛俊??瀹??ㄧ???у?惰?藉??寰?寮? 涓???楂?搴??哄????淇℃??绯葷?????/S 缁?????瀹?. ??浠ラ??杩?B/S??甯??ㄥ??????寮?淇℃??.

????B/S 寤虹???ㄥ箍??缃?涔?涓?, 瀵瑰???ㄧ???у?惰?藉???稿?瑰急, ???介?㈠??涓????ョ???ㄦ?楓??

锛?锛?瀵圭?搴??舵??涓???

????C/S 绋?搴???浠ユ?村??娉ㄩ??娴?绋?, ??浠ュ?規????澶?灞?娆℃?¢??, 瀵圭郴缁?杩?琛???搴???浠ヨ?灏?????.

????B/S 瀵瑰???ㄤ互??璁塊????搴???澶?????????, 寤虹???ㄩ??瑕??村??浼??????虹?涔?涓?. 姣?C/S???撮????瑕?姹? B/S缁?????绋?搴??舵??????灞???瓒??? 浠?MS??.Net绯誨????BizTalk 2000 Exchange 2000绛?, ?ㄩ?㈡????缃?缁?????浠舵??寤虹??绯葷?. SUN ??IBM?ㄧ??JavaBean ??浠舵????绛?,浣?B/S?村??????.

锛?锛?杞?浠堕???ㄤ???

????C/S 绋?搴???浠ヤ????垮?????翠??ц????, ??浠剁?????ㄦ?т?濡???/S瑕?姹?涓?????浠剁?????ㄦ?уソ.

????B/S 瀵圭??澶???缁???,瑕?姹???浠剁?稿?圭??绔??????? ?藉??稿?矽?濂界??????灏卞?ヤ拱?ョ??椁?妗???浠ュ???╃????涓??????ㄥ?涓????沖ご妗?瀛?

锛?锛?绯葷?缁存?や????

????C/S 绋?搴??變??翠??? 蹇?椤繪?翠???瀵?, 澶????虹?扮????棰?浠ュ??绯葷???绾? ??绾ч?? ???芥??????涓?涓??ㄦ?扮??绯葷?

????B/S ??浠剁???,?歸?㈡??浠朵釜?????存??瀹??扮郴缁?????缂???绾? 绯葷?缁存?ゅ??????版??灏?.?ㄦ?蜂?缃?涓???宸變?杞藉??瑁?灏卞??浠ュ???闆??绾?

锛?锛?澶?????棰?涓???

????C/S 绋?搴???浠ュ????ㄦ?烽?㈠?哄??, 骞朵??ㄧ?稿???哄??, 瀹??ㄨ?姹?楂???姹?, 涓???浣?绯葷??稿?? 搴?璇ラ?芥???稿????绯葷?

????B/S 寤虹???ㄥ箍??缃?涓?, ?㈠??涓??????ㄦ?風兢, ???e?闆??, 杩???C/S??娉?浣??扮??. 涓???浣?绯葷?骞沖?闆?崇郴??灏?.

锛?锛??ㄦ?鋒?ュ?d???

????C/S 澶???寤虹????Window骞沖?頒?,琛ㄧ?版?規?????,瀵圭?搴???????瑕?姹?杈?楂?

????B/S 寤虹???ㄦ?瑙??ㄤ?, ???村??涓闆???????ㄧ??琛ㄧ?版?瑰?涓??ㄦ?蜂氦娴?. 骞朵?澶ч?ㄥ???懼害??浣?,??浣?寮???????.

锛?锛?淇℃??娴?涓???

????C/S 绋?搴?涓??????稿????涓?澶????????烘?寮?澶???, 浜や??х?稿?逛?

????B/S 淇℃??娴?????????, B-B B-C B-G绛?淇℃????娴?????????, ?村??浜ゆ??涓?蹇???

118??LINUX涓?绾跨?锛?GDI绫葷??瑙i????

LINUX瀹??扮??灏辨???轟??稿?杞婚??绾ц?绋???"涓?瀵逛?"绾跨?妯″??锛?涓?涓?绾跨?瀹?浣?瀵瑰?涓?涓??稿?杞婚??绾ц?绋?锛???绾跨?涔??寸??绠$???ㄦ?稿??芥?闆?涓?瀹??般??

GDI绫諱負?懼??璁懼?缂?绋??ュ?g被搴???

119??STRUTS??搴???濡?STRUTS?舵??)

Struts??????ava Servlet/JavaServer Pages????锛?寮???Web搴??ㄧ?搴???寮??炬?????framework?? ????truts?藉????哄?轟?MVC(Model-View-Controller)璁捐?℃ā寮???搴??ㄦ???躲?? Struts??濡?涓???涓昏????斤? 涓?.????涓?涓?controller servlet锛??藉??ㄦ?風??璇鋒??????扮?稿???Action瀵矽薄??浜?.JSP????ag搴?锛?骞朵???ontroller servlet涓???渚??寵??????锛?甯??╁???????寤轟氦浜?寮?琛ㄥ??搴??ㄣ?? 涓?.??渚?浜?涓?绯誨??瀹??ㄥ?矽薄锛?XML澶???????杩?Java reflection APIs???ㄥ???JavaBeans灞??с???介????????绀哄??娑?????

120??Jdo??浠?涔??

JDO??Java瀵矽薄??涔??????扮??瑙???锛?涓?ava data object??绠?绉?涔???涓?涓??ㄤ?瀛?????绉??版??浠?搴?涓???瀵矽薄????????API??JDO??渚?浜???????瀵矽薄瀛??????姝ゅ?瑰???浜哄???ヨ?達?瀛??ㄦ?版??瀵矽薄瀹??ㄤ???瑕?棰?澶???浠g??锛?濡?JDBC API??浣跨?????杩?浜?绻?????渚?琛?宸ヤ?宸茬?杞?绉誨??DO浜у????渚???韬?涓?锛?浣垮???浜哄??瑙h?卞?烘?ワ?浠?????涓??堕?村??绮懼???ㄤ??¢?昏?涓??????锛?JDO寰??墊椿锛???涓哄????浠ュ?ㄤ換浣??版??搴?灞?涓?杩?琛???JDBC?????㈠???崇郴?版??搴?锛?RDBMS锛?JDO?撮???????渚??頒換浣??版??搴?灞???瀛??ㄥ???斤?姣?濡??崇郴?版??搴?????浠躲??XML浠ュ??瀵矽薄?版??搴?锛?ODBMS锛?绛?绛?锛?浣垮?搴??ㄥ??绉繪??ф?村己??

121?????ㄧ被??浠ュ??ㄤ?????绫葷????????锛???娌℃??浠?涔????訛?

涓?涓????ㄧ被瀵矽薄??浠ヨ?塊????寤哄????澶??ㄧ被瀵矽薄????瀹?122??WEB SERVICE??璇?瑙i????JSWDL寮???????浠?缁???JAXP??JAXM??瑙i????SOAP??UDDI,WSDL瑙i????

Web ServiceWeb Service???轟?缃?缁???????甯?寮???妯″????缁?浠訛?瀹??ц??瑰????浠誨?★??靛???蜂???????瑙???锛?杩?浜?瑙???浣垮?Web Service?戒??朵??煎?圭??缁?浠惰?琛?浜???浣???

JAXP(Java API for XML Parsing) 瀹?涔?浜???ava涓?浣跨??OM, SAX, XSLT?????ㄧ???ュ?c??杩??峰?ㄤ???绋?搴?涓?浣???瑕?浣跨?ㄨ?浜????ㄧ???ュ?o?褰?浣???瑕??瑰???蜂???瀹??版?跺??涔?涓???瑕?淇??逛唬????

JAXM(Java API for XML Messaging) ??涓?OAP??淇℃??渚?璁塊???規???浼?杈??哄?剁??API??

WSDL??涓?绉? XML ?煎?锛??ㄤ?灏?缃?缁????℃??杩頒負涓?缁?绔??癸?杩?浜?绔??瑰?瑰?????㈠????妗d俊?????㈠??杩?绋?淇℃????娑???杩?琛???浣???杩?绉??煎?棣???瀵規??浣???娑???杩?琛??借薄??杩幫??跺??灏??剁?瀹??闆?蜂???缃?缁???璁???娑????煎?涓?浠ュ??涔?绔??廣???稿?崇???蜂?绔??瑰?崇?????涓烘?借薄绔??癸????★???

SOAP?崇????瀵矽薄璁塊????璁?(Simple Object Access Protocol)锛?瀹????ㄤ?浜ゆ??ML缂???淇℃????杞婚??绾у??璁???

UDDI ????????涓虹?靛?????″緩绔?????锛?UDDI??涓?濂??轟?Web??????甯?寮?????涓?eb Service??渚?????淇℃??娉ㄥ??涓?蹇???瀹??版????瑙???锛????朵?????涓?缁?浣誇?涓??藉???韬???渚???Web Service娉ㄥ??锛?浠ヤ嬌????浼?涓??藉????扮??璁塊????璁???瀹??版??????

JAVA 浠g???ラ??

1.

abstract class Name {

?? private String name;

?? public abstract boolean isStupidName(String name) {}

}

澶т?浠?锛?杩???浣???璇??

绛?妗?: ????abstract method蹇?椤諱互???風?灏撅?涓?涓?甯??辨???楓??

2.

public class Something {

?? void doSomething () {

?????? private String s = "";

?????? int l = s.length();

?? }

}

???????

绛?妗?: ????灞??ㄥ??????涓??芥?劇疆浠諱?璁塊??淇?楗扮??(private锛?public锛???protected)??final??浠ョ?ㄦ?ヤ慨楗闆??ㄥ????

(final濡???abstract??strictfp锛??芥????璁塊??淇?楗扮???strictfp???戒慨楗?lass??method????variable)??

3.

abstract class Something {

?? private abstract String doSomething ();

}

杩?濂藉??娌′?涔?????

绛?妗?: ????abstract??methods涓??戒互private淇?楗般??abstract??methods灏辨??璁╁??绫?mplement(瀹????蜂?缁?????锛???涔???浠ョ??rivate??abstract

method灏???璧鋒?ュ?? (????锛?abstract method??涓??藉??final)??

4.

public class Something {

?? public int addOne(final int x) {

?????? return ++x;

?? }

}

杩?涓?姣?杈????俱??

绛?妗?: ????int x琚?淇?楗版??final锛????崇??x涓??藉??ddOne method涓?琚?淇??廣??

5.

public class Something {

?? public static void main(String[] args) {

?????? Other o = new Other();

?????? new Something().addOne(o);

?? }

?? public void addOne(final Other o) {

?????? o.i++;

?? }

}

class Other {

?? public int i;

}

??涓??㈢??寰??鎬技锛??芥???充?final????棰?锛?杩????????

绛?妗?: 姝g‘????ddOne method涓?锛?????琚?淇?楗版??final??濡?????ddOne method????浠?淇??逛?o??reference

(姣?濡?: o = new Other();)锛??d?濡???涓?渚?杩?棰?涔?????????浣?杩???淇??圭????o??member vairable

(????????)锛???o??reference骞舵病???瑰????

6.

class Something {

??? int i;

??? public void doSomething() {

??????? System.out.println("i = " + i);

??? }

}

??浠?涔????? ??涓??烘?ュ????

绛?妗?: 姝g‘??杈??虹????"i = 0"??int i灞???nstant variable (瀹?渚?????锛?????????????)??instant variable??default value??int??default value??0??

7.

class Something {

??? final int i;

??? public void doSomething() {

??????? System.out.println("i = " + i);

??? }

}

??涓????棰?????涓?涓??版?逛???锛?灏辨??澶?浜?涓?涓?final??杩??鵑??灏遍??浜????

绛?妗?: ????final int i??涓?final??instant variable (瀹?渚?????锛?????????????)??final??instant variable娌℃??default value锛?蹇?椤誨??onstructor (??????缁???涔???琚?璧?浜?涓?涓???纭????箋????浠ヤ慨?逛負"final int i = 0;"??

8.

public class Something {

???? public static void main(String[] args) {

??????? Something s = new Something();

??????? System.out.println("s.doSomething() returns " + doSomething());

??? }

??? public String doSomething() {

??????? return "Do something ...";

??? }

}

???涓??誨?瀹?缇???

绛?妗?: ??????涓??誨??ain??call doSomething娌℃??浠?涔???棰?锛?姣?绔?涓や釜methods?藉?ㄥ??涓?涓?class????浣?浠?缁???锛?main??static????static method涓??界?存??all non-static methods?????規??"System.out.println("s.doSomething() returns " + s.doSomething());"??????锛?static method涓??借?塊??non-static instant variable??

9.

姝ゅ?锛?Something绫葷????浠跺????OtherThing.java

class Something {

??? private static void main(String[] something_to_do) {???????

??????? System.out.println("Do something ...");

??? }

}

?杩?涓?濂藉??寰????俱??

绛?妗?: 姝g‘??浠??ユ病??浜鴻?磋?Java??Class??瀛?蹇?椤誨???舵??浠跺???稿????浣?public class????瀛?蹇?椤誨????浠跺???稿????

10锛?

interface? A{

?? int x = 0;

}

class B{

?? int x =1;

}

class C extends B implements A {

?? public void pX(){

????? System.out.println(x);

?? }

?? public static void main(String[] args) {

????? new C().pX();

?? }

}

绛?妗?锛???璇????ㄧ?璇??朵???????璇?(??璇???杩頒?????JVM??涓?????淇℃??锛?????灏辨??????纭???x璋????涓や釜x?藉?歸??锛?灏辮薄?ㄥ????mport java.util??java.sql涓や釜???剁?存?ュ0??Date涓??鳳???瀵逛??剁被??????,??浠ョ??uper.x?ユ??纭?锛????ュ?g??灞??ч?璁ら????涓?public static final.??浠ュ??浠ラ??杩?A.x?ユ??纭???

11.

interface Playable {

??? void play();

}

interface Bounceable {

??? void play();

}

interface Rollable extends Playable, Bounceable {

??? Ball ball = new Ball("PingPang");

}

class Ball implements Rollable {

??? private String name;

??? public String getName() {

??????? return name;

??? }

??? public Ball(String name) {

??????? this.name = name;???????

??? }

?? public void play() {

??????? ball = new Ball("Football");

??????? System.out.println(ball.getName());

??? }

}

杩?涓???璇?涓?瀹規?????般??

绛?妗?: ????"interface Rollable extends Playable, Bounceable"娌℃????棰???interface??缁ф?垮?涓?interfaces锛???浠ヨ???娌¢??????棰??哄??nterface Rollable????"Ball ball = new Ball("PingPang");"??浠諱???nterface??澹版????interface variable (?ュ?e????锛?涔???绉版????????)锛?榛?璁や負public static final??涔?灏辨??璇?Ball ball = new Ball("PingPang");"瀹???涓???"public static final Ball ball = new Ball("PingPang");"????all绫葷??Play()?規?涓?锛?"ball = new Ball("Football");"?瑰??浜?ball??reference锛???杩?????ball?ヨ??Rollable interface锛?Rollable interface????ball??public static final??锛?final??object??涓??借??瑰??reference??????姝ょ?璇??ㄥ???ball = new Ball("Football");"杩????劇ず??????

JAVA 缂?绋?棰?

1锛??闆?ㄨ???涓??闆??锛?浠ラ???鳳???寮?锛??跺???????╁????????搴???搴?锛?????浜ら??灏卞?ㄥ???椤甸?㈡?劇ず??浠?涔???搴?锛?缁???涓猴???渚?reset

import java.util.*;

public class bycomma{

?public static String[] splitStringByComma(String source){

?? if(source==null||source.trim().equals(""))

??? return null;

?? StringTokenizer commaToker = new StringTokenizer(source,",");

?? String[] result = new String[commaToker.countTokens()];

?? int i=0;

?? while(commaToker.hasMoreTokens()){

??? result[i] = commaToker.nextToken();

??? i++;

?? }

?? return result;

?}

?public static void main(String args[]){

?String[] s = splitStringByComma("5,8,7,4,3,9,1");

?int[] ii = new int[s.length];

?for(int i = 0;i<s.length;i++){

?ii[i] =Integer.parseInt(s[i]);

?}

??? Arrays.sort(ii);

??? //asc

??? for(int i=0;i<s.length;i++){

??? System.out.println(ii[i]);

??? }

??? //desc

??? for(int i=(s.length-1);i>=0;i--){

??? System.out.println(ii[i]);

??? }

?}

}

2锛???棰?杞?????挎??浼??闆??????棰?杞??㈡??涓??戒?缁???褰㈠?濡?锛?锛?锟?011锛?锛?>锛?涓????朵??句????達?杈??恒??

package test.format;

import java.text.NumberFormat;

import java.util.HashMap;

public class SimpleMoneyFormat {

? public static final String EMPTY = "";

? public static final String ZERO = "??;

? public static final String ONE = "澹?;

? public static final String TWO = "璐?;

? public static final String THREE = "??";

? public static final String FOUR = "??";

? public static final String FIVE = "浼?";

? public static final String SIX = "??";

? public static final String SEVEN = "??";

? public static final String EIGHT = "??";

? public static final String NINE = "??";

? public static final String TEN = "??;

? public static final String HUNDRED = "浣?;

? public static final String THOUSAND = "浠?";

? public static final String TEN_THOUSAND = "涓?";

? public static final String HUNDRED_MILLION = "浜?;

? public static final String YUAN = "??";

? public static final String JIAO = "瑙?";

? public static final String FEN = "??";

? public static final String DOT = "."; ? private static SimpleMoneyFormat formatter = null;

? private HashMap chineseNumberMap = new HashMap();

? private HashMap chineseMoneyPattern = new HashMap();

? private NumberFormat numberFormat = NumberFormat.getInstance(); ? private SimpleMoneyFormat() {

??? numberFormat.setMaximumFractionDigits(4);

??? numberFormat.setMinimumFractionDigits(2);

??? numberFormat.setGroupingUsed(false); ??? chineseNumberMap.put("0", ZERO);

??? chineseNumberMap.put("1", ONE);

??? chineseNumberMap.put("2", TWO);

??? chineseNumberMap.put("3", THREE);

??? chineseNumberMap.put("4", FOUR);

??? chineseNumberMap.put("5", FIVE);

??? chineseNumberMap.put("6", SIX);

??? chineseNumberMap.put("7", SEVEN);

??? chineseNumberMap.put("8", EIGHT);

??? chineseNumberMap.put("9", NINE);

??? chineseNumberMap.put(DOT, DOT); ??? chineseMoneyPattern.put("1", TEN);

??? chineseMoneyPattern.put("2", HUNDRED);

??? chineseMoneyPattern.put("3", THOUSAND);

??? chineseMoneyPattern.put("4", TEN_THOUSAND);

??? chineseMoneyPattern.put("5", TEN);

??? chineseMoneyPattern.put("6", HUNDRED);

??? chineseMoneyPattern.put("7", THOUSAND);

??? chineseMoneyPattern.put("8", HUNDRED_MILLION);

? } ? public static SimpleMoneyFormat getInstance() {

??? if (formatter == null)

????? formatter = new SimpleMoneyFormat();

??? return formatter;

? } ? public String format(String moneyStr) {

??? checkPrecision(moneyStr);

??? String result;

??? result = convertToChineseNumber(moneyStr);

??? result = addUnitsToChineseMoneyString(result);

??? return result;

? } ? public String format(double moneyDouble) {

??? return format(numberFormat.format(moneyDouble));

? } ? public String format(int moneyInt) {

??? return format(numberFormat.format(moneyInt));

? } ? public String format(long moneyLong) {

??? return format(numberFormat.format(moneyLong));

? } ? public String format(Number moneyNum) {

??? return format(numberFormat.format(moneyNum));

? } ? private String convertToChineseNumber(String moneyStr) {

??? String result;

??? StringBuffer cMoneyStringBuffer = new StringBuffer();

??? for (int i = 0; i < moneyStr.length(); i++) {

????? cMoneyStringBuffer.append(chineseNumberMap.get(moneyStr.substring(i, i + 1)));

??? }

??? // ?句槳浠?涓?浜跨???芥??姹?瀛????㈡????????浣?锛???涓?瀹?浠?

??? int indexOfDot = cMoneyStringBuffer.indexOf(DOT);

??? int moneyPatternCursor = 1;

??? for (int i = indexOfDot - 1; i > 0; i--) {

????? cMoneyStringBuffer.insert(i, chineseMoneyPattern.get(EMPTY + moneyPatternCursor));

????? moneyPatternCursor = moneyPatternCursor == 8 ? 1 : moneyPatternCursor + 1;

??? } ??? String fractionPart = cMoneyStringBuffer.substring(cMoneyStringBuffer.indexOf("."));

??? cMoneyStringBuffer.delete(cMoneyStringBuffer.indexOf("."), cMoneyStringBuffer.length());

??? while (cMoneyStringBuffer.indexOf(" ?舵??) != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?舵??), cMoneyStringBuffer.indexOf("?舵??) + 2, ZERO);

??? }

??? while (cMoneyStringBuffer.indexOf("?朵槳") != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?朵槳"), cMoneyStringBuffer.indexOf("?朵槳") + 2, ZERO);

??? }

??? while (cMoneyStringBuffer.indexOf("?朵?") != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?朵?"), cMoneyStringBuffer.indexOf("?朵?") + 2, ZERO);

??? }

??? while (cMoneyStringBuffer.indexOf("?朵?") != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?朵?"), cMoneyStringBuffer.indexOf("?朵?") + 2, TEN_THOUSAND);

??? }

??? while (cMoneyStringBuffer.indexOf("?朵嚎") != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?朵嚎"), cMoneyStringBuffer.indexOf("?朵嚎") + 2, HUNDRED_MILLION);

??? }

??? while (cMoneyStringBuffer.indexOf("?堕??) != -1) {

????? cMoneyStringBuffer.replace(cMoneyStringBuffer.indexOf("?堕??), cMoneyStringBuffer.indexOf("?堕??) + 2, ZERO);

??? }

??? if (cMoneyStringBuffer.lastIndexOf(ZERO) == cMoneyStringBuffer.length() - 1)

????? cMoneyStringBuffer.delete(cMoneyStringBuffer.length() - 1, cMoneyStringBuffer.length());

??? cMoneyStringBuffer.append(fractionPart); ??? result = cMoneyStringBuffer.toString();

??? return result;

? }

? private String addUnitsToChineseMoneyString(String moneyStr) {

??? String result;

??? StringBuffer cMoneyStringBuffer = new StringBuffer(moneyStr);

??? int indexOfDot = cMoneyStringBuffer.indexOf(DOT);

??? cMoneyStringBuffer.replace(indexOfDot, indexOfDot + 1, YUAN);

? ? ?