锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲免费中文字幕,伊人久久五月丁香综合中文亚洲 ,亚洲AV乱码久久精品蜜桃http://m.tkk7.com/JafeLee/category/22866.htmlzh-cnMon, 10 Dec 2007 15:31:55 GMTMon, 10 Dec 2007 15:31:55 GMT60Java 姝e垯琛ㄨ揪寮?(2) -- Metacharacters & Character Classeshttp://m.tkk7.com/JafeLee/archive/2007/12/10/166494.htmlJafeJafeMon, 10 Dec 2007 01:58:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/12/10/166494.htmlhttp://m.tkk7.com/JafeLee/comments/166494.htmlhttp://m.tkk7.com/JafeLee/archive/2007/12/10/166494.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/166494.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/166494.html([{\^-$|]})?*+.銆傛敞鎰忥紝鍦ㄦ煇浜涙椂鍊欒繖浜涚壒孌婄殑瀛楃騫朵笉涓瀹氫唬琛ㄧ壒孌婂惈涔夛紝渚嬪 - 鍦╗a-c]涓槸鍏冨瓧絎︼紝浣嗗湪 a-c 鍒欎笉琛ㄧず鐗規畩鍚箟銆備笉榪囦笂闈㈡病鍒楀嚭鐨勫瓧絎﹀垯涓瀹氫笉浼氫唬琛ㄧ壒孌婂惈涔夈?br />
2銆佸彲浠ュ鍏冨瓧絎﹁繘琛岃漿涔夛紝涓昏鏈変袱縐嶆柟娉曪細
  • 鍦ㄥ厓瀛楃鍓嶉潰鍔犱竴涓弽鏂滄潬 (backslash錛塡
  • 鐢?\Q 鍜?\E鍖呭惈璧鋒潵錛屼緥濡?\? == \Q?\E
3銆丆haracter Classes 錛氳繖閲岀殑class騫朵笉鏄疛ava涓殑class錛屽湪姝e垯琛ㄨ揪寮忎腑錛屼竴涓猚haracter class鏄敱涓緋誨垪鍖呭惈鍦ㄦ柟鎷彿涓殑瀛楃緇勬垚錛屽畠鑳藉湪杈撳叆鐨勪竴緋誨垪瀛楃涓蹭腑鍖歸厤涓涓瓧絎︼紝渚嬪[a-d]鍖歸厤a, b, c, d,涓殑浠諱綍涓涓瓧絎︺傚啀鐪嬩笅闈竴涓緥瀛愶紙鎽樿嚜java.sun.com錛?br />

Character Classes
[abc] a, b, or c (simple class)
[^abc] Any character except a, b, or c (negation)
[a-zA-Z] a through z, or A through Z, inclusive (range)
[a-d[m-p]] a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]] d, e, or f (intersection)
[a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction)
[a-z&&[^m-p]] a through z, and not m through p: [a-lq-z] (subtraction)

4銆丆haracter Classes 涔嬮棿鐨勮繍綆楋細浠庝笂闈㈢殑琛ㄦ牸涔熷彲浠ョ湅鍑?character classes鍖呭惈浜嗗嚑涓窡闆嗗悎鎿嶄綔寰堢浉浼肩殑鎿嶄綔錛氫緥濡俷egation錛堣ˉ錛夈乽nion(騫訛級銆乮ntersection(浜わ級銆乻ubtraction(宸級銆傜敱涓婇潰鐨勮〃鏍間篃鍙互鐪嬪嚭涓や釜Character Classes涔嬮棿鐨勮繍綆楀彧闇瑕佺畝鍗曞湴灝嗕竴涓狢haracter Classes宓屽叆鍒板彟涓涓狢haracter Classes騫朵嬌鐢ㄦ紜殑鎿嶄綔絎﹀氨鍙互浜嗐?br />
5銆丳redefined Character Classes錛歫ava.util.regex.* 鍖呭惈浜嗕竴浜涢鍏堝畾涔夌殑 Character Classes,鍦ㄥ疄闄呬腑鍙互寰堟柟渚垮湴榪愮敤錛氾紙鎽樿嚜 java.sun.com )

Predefined Character Classes
. Any character (may or may not match line terminators)
\d A digit: [0-9]
\D A non-digit: [^0-9]
\s A whitespace character: [ \t\n\x0B\f\r]
\S A non-whitespace character: [^\s]
\w A word character: [a-zA-Z_0-9]
\W A non-word character: [^\w]



Jafe 2007-12-10 09:58 鍙戣〃璇勮
]]>
Java 姝e垯琛ㄨ揪寮?(1) -- java.util.regex.* 浠嬬粛http://m.tkk7.com/JafeLee/archive/2007/12/09/166489.htmlJafeJafeSun, 09 Dec 2007 11:47:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/12/09/166489.htmlhttp://m.tkk7.com/JafeLee/comments/166489.htmlhttp://m.tkk7.com/JafeLee/archive/2007/12/09/166489.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/166489.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/166489.html
  • Pattern : 鐢ㄦ潵琛ㄧず涓涓粡榪囩紪璇戝鐞嗗悗鐨勬鍒欒〃杈懼紡銆傞氫織涓鐐規潵璇達紝灝辨槸鐢ㄤ竴涓被鏉ヨ〃紺轟竴涓鍒欒〃杈懼紡錛岃繖涓被鏄粠姝e垯琛ㄨ揪寮忔瀯閫犲緱鍒扮殑銆傝繖涓被騫舵病鏈塸ublic constructor, 濡傛灉鎯沖緱鍒頒竴涓繖涓被鐨勪竴涓璞″垯蹇呴』璋冪敤璇ョ被鐨刾ublic static鏂規硶錛歱ublic static Pattern compile(String regex)鎴栬?public static Pattern compile(String regex,int flags)銆傝繖涓や釜鏂規硶榪斿洖涓涓狿attern鍨嬬殑瀵硅薄銆?/li>
  • Matcher : 瑙i噴Pattern騫舵墽琛屽尮閰嶃佹煡鎵懼伐浣滅殑綾伙紝璺烶attern綾諱竴鏍鳳紝榪欎釜綾諱篃娌℃湁瀹氫箟public constructor錛岃鎯寵幏寰椾竴涓狹atcher瀵硅薄蹇呴』璋冪敤Pattern綾葷殑鏂規硶 public Matcher matcher(CharSequence input) 鏉ュ緱鍒般?/li>
  • PatternSyntaxException : 涓涓猽nchecked exception銆傚綋閬囧埌涓嶇鍜孞ava姝e垯琛ㄨ揪寮忕殑璇硶鐨勬椂鍊欑▼搴忓氨浼氭姏鍑鴻繖涓紓甯搞?/li>
2銆佷竴涓緥瀛愶紙鎽樿嚜java.sun.com 錛?br />
package聽regex;

import
聽java.io.Console;
import聽java.util.regex.Pattern;
import聽java.util.regex.Matcher;

publicclass聽RegexTestHarness聽{
聽聽聽聽
publicstaticvoid聽main(String聽[]聽args)聽{
聽聽聽聽聽聽聽聽Console聽console聽
=聽System.console();
聽聽聽聽聽聽聽聽
if聽(console聽==null)聽{
聽聽聽聽聽聽聽聽聽聽聽聽System.err.println(
"No聽console.");
聽聽聽聽聽聽聽聽聽聽聽聽System.exit(
1);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
while聽(true)聽{
聽聽聽聽聽聽聽聽聽聽聽聽Pattern聽pattern聽
=聽Pattern.compile(console.readLine("%nEnter聽your聽regex:聽"));
聽聽聽聽聽聽聽聽聽聽聽聽Matcher聽matcher聽
=聽pattern.matcher(console.readLine("Enter聽input聽string聽to聽search:聽"));
聽聽聽聽聽聽聽聽聽聽聽聽
boolean聽found聽=false;
聽聽聽聽聽聽聽聽聽聽聽聽
while聽(matcher.find())聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽console.format(
"I聽found聽the聽text聽\"%s\"starting聽at聽"+
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
"index聽%d聽and聽ending聽at聽index聽%d.聽%n",聽matcher.group(),聽matcher.start(),聽matcher.end());
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽found聽
=true;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
if聽(!found)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽console.format(
"No聽match聽found.%n");
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}
娉細鐢變簬榪欎釜渚嬪瓙浣跨敤浜咼DK 1.6鍚庢墠鏈夌殑鏂規硶錛歋ystem.console(),鎵浠ヨ繖涓緥瀛愬湪eclipse鍜宯etbeans閮戒笉鑳芥甯歌繍琛屻傚彧鏈夊湪鍛戒護琛屼笅鎵嶈兘姝g‘榪愯銆傚鏋滄兂鍦╡clipse鍜宯b涓嬭繍琛岋紝濂藉儚鍙互鐢⊿ystem.out/in鏉ヤ唬鏇縎ystem.console銆?br />

Jafe 2007-12-09 19:47 鍙戣〃璇勮
]]>
Java Thread (1)http://m.tkk7.com/JafeLee/archive/2007/09/12/144519.htmlJafeJafeWed, 12 Sep 2007 13:32:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/09/12/144519.htmlhttp://m.tkk7.com/JafeLee/comments/144519.htmlhttp://m.tkk7.com/JafeLee/archive/2007/09/12/144519.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/144519.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/144519.html
  • 緇ф壙綾籮ava.lang.Thread 錛岃鐩栧叾涓殑鏂規硶 run(); 瀹炰緥鍖栬瀛愮被錛屼緥濡傦細
    publicclass聽MyThread聽extends聽Thread聽
    {
    聽聽聽
    publicvoid聽run()聽
    聽聽{
    聽聽聽聽聽聽
    //聽do聽some聽work
    聽聽聽}
    }
    //聽code聽to聽use聽MyThread
    new聽MyThread().start();
  • 瀹氫箟涓涓疄鐜版帴鍙?java.lang.Runnable; 鐨勭被錛屽疄鐜拌鎺ュ彛鐨勬柟娉時un(); 鐒跺悗灝嗚綾葷殑涓涓疄渚嬩綔涓哄疄鍙備紶緇橳hread鐨勬瀯閫犳柟娉曘備緥濡傦細
    publicclass聽MyThread2聽implements聽Runnable聽
    {
    聽聽聽
    publicvoid聽run()聽
    聽聽{
    聽聽聽聽聽聽
    //聽do聽some聽work
    聽聽聽}
    }

    //聽code聽to聽use聽MyThread2
    Thread聽t聽=new聽Thread(MyThread2);
    t.start();
  • 鏃犺鐢ㄥ摢縐嶆柟娉曟渶緇堝緱鍒扮殑閮芥槸涓涓猅hread鐨刼bject錛屽綋璋冪敤鏂規硶start()鏃訛紝緋葷粺灝嗗垱寤轟竴涓柊鐨勭嚎紼嬫潵鎵цrun() 鏂規硶錛岃繖涓柊鐨勭嚎紼嬪皢涓鐩磋繍琛岀煡閬搑un鏂規硶閫鍑恒傚湪鏂扮嚎紼嬪紑濮嬭繍琛岀殑鍚屾椂錛屽師鏉ョ殑綰跨▼涔熷皢緇х畫鎵цstart()涔嬪悗鐨勪唬鐮併?/span>
2銆佷竴涓嚎紼嬬殑鐢熷懡鍛ㄦ湡錛氭瘡涓嚎紼嬬殑鐢熷懡鍛ㄦ湡(lifecycle)涓鍏辨湁鍏釜鐘舵?state)錛岃繖鍏釜鐘舵佺敤鏋氫婦綾誨瀷Thread.State鐨勫叚涓灇涓懼父閲忔潵琛ㄧず銆傚垎鍒槸錛?br />3銆佺嚎紼嬩紭鍏堢駭錛氱嚎紼嬪彲浠ユ湁涓嶅悓浼樺厛綰э紝Thread瀹氫箟浜嗕笁涓紭鍏堢駭甯擱噺錛?br />
publicfinalstaticint聽MIN_PRIORITY聽=1;聽//鏈灝忎紭鍏堢駭
publicfinalstaticint聽NORM_PRIORITY聽=5;聽//榛樿鐨勪紭鍏堢駭
publicfinalstaticint聽MAX_PRIORITY聽=10;聽//鏈澶т紭鍏堢駭
涓涓嚎紼嬬殑浼樺厛綰у彲浠ユ槸1鍒?0涓換浣曚竴涓暣鏁幫紙鍖呮嫭1鍜?0).鏂規硶 void setPriority(int newPriority) 鍙互鐢ㄦ潵璁劇疆綰跨▼鏈夐檺綰с傚叧浜庝紭鍏堢駭闇瑕佹敞鎰忕殑鏄紝璋冨害鍣ㄦ繪槸閫夋嫨浼樺厛綰ф渶楂樼殑綰跨▼鏉ユ墽琛岋紝浣嗘槸java鐨勭嚎紼嬩紭鍏堢駭鏄拰鎿嶄綔緋葷粺鐩稿叧鐨勶紝渚嬪windows XP緋葷粺鏈?涓紭鍏堢駭錛宩ava涓殑鏌愪簺浼樺厛綰т細瀵瑰簲鍒皒p鐨?涓紭鍏堢駭涓幓銆備絾鏄疭UN 鐨刲inux鐗堟湰鐨凧VM涓婃墍鏈夌嚎紼嬬殑浼樺厛綰ч兘鏄疦ORM_PRIORITY銆傚湪浣跨敤浼樺厛綰х殑鍚屾椂涔熻閬垮厤楗挎鐨勬儏鍐靛嚭鐜般?br />
4銆佸鐞?uncaught exceptions:
褰撲竴涓嚎紼嬬殑run()鏂規硶鎵ц瀹屾瘯鎴栬卹un()鏂規硶鎵цreturn璇彞鏃訛紝綰跨▼姝e父涓銆傚綋run鏂規硶鎶涘嚭涓涓猽nchecked寮傚父鏃訛紙娉ㄦ剰錛歳un鏂規硶鏄笉鑳芥姏鍑篶hecked寮傚父鐨勶級錛岀嚎紼嬩篃浼氫腑姝㈠茍涓旀墦鍗板嚭寮傚父淇℃伅銆傚鏋滀綘鎯蟲崟鑾峰鐞嗚寮傚父錛屽垯蹇呴』涓鴻綰跨▼娣誨姞涓涓猽ncaught exception handler鏉ユ墽琛屻備緥濡傦細
package聽uncaughtexception;
publicclass聽MyThread聽implements聽Runnable
{
聽聽聽聽@Override
聽聽聽聽
publicvoid聽run()
聽聽聽聽{
聽聽聽聽聽聽聽聽
thrownew聽UnsupportedOperationException();
聽聽聽聽}
}


package聽uncaughtexception;

publicclass聽TestMyThread
{
聽聽聽聽
publicstaticvoid聽main(String聽[]聽args)
聽聽聽聽{
聽聽聽聽聽聽聽聽Thread聽aThread聽
=new聽Thread(new聽MyThread());
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽aThread.setUncaughtExceptionHandler(
new聽Thread.UncaughtExceptionHandler()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽@Override
聽聽聽聽聽聽聽聽聽聽聽聽
publicvoid聽uncaughtException(Thread聽t,聽Throwable聽e)
聽聽聽聽聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Hello");
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽});
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽aThread.start();
聽聽聽聽}
}
榪愯緇撴灉: Hello


Jafe 2007-09-12 21:32 鍙戣〃璇勮
]]>
Java Enumeration (鏋氫婦綾誨瀷) (5) -- Value-specific class bodyhttp://m.tkk7.com/JafeLee/archive/2007/09/09/143793.htmlJafeJafeSun, 09 Sep 2007 07:29:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/09/09/143793.htmlhttp://m.tkk7.com/JafeLee/comments/143793.htmlhttp://m.tkk7.com/JafeLee/archive/2007/09/09/143793.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/143793.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/143793.html
ArithmeticOp.java

TestOperator.java

  1. 瀹氫箟姣忎竴涓?value-specific class body 錛堜笉鐭ュ浣曠炕璇憕~)灝嗕細鍒涘緩涓涓鏋氫婦綾誨瀷鐨勫尶鍚嶅瓙綾伙紙anonymous subclass), 瀵瑰簲鐨勬灇涓懼父閲忓皢浼氬敮涓鐨勬寚鍚戣瀛愮被銆傝繖閲岄渶瑕佹敞鎰忕殑鏄紝灝界鏋氫婦綾誨瀷涓嶈兘琚玡xtends錛屼絾鏄畠鍗村彲浠ユ嫢鏈夊尶鍚嶅瓙綾伙紝浠庤繖涓剰涔変笂鏉ヨ錛屾灇涓劇被鍨嬪茍涓嶆槸涓涓弗鏍肩殑final綾匯?/li>
  2. 鍖垮悕瀛愮被灝遍紺虹潃榪欎簺瀛愮被娌℃湁鑷繁鐨刢onstructor錛屼綘涔熶笉鑳藉湪浣犵殑浠g爜涓紩鐢ㄤ竴浜涘尶鍚嶅瓙綾昏嚜宸辨嫢鏈夌殑鏂規硶鎴栧煙錛堣涓婇潰渚嬪瓙ADD涓殑justForAdd鏂規硶錛夛紝榪欐槸鍥犱負姣忎釜鏋氫婦綾誨瀷鐨勬灇涓懼父閲忕殑鏋氫婦綾誨瀷閮芥槸璇ユ灇涓劇被鍨嬬殑銆傚彲鑳借繖鍙ヨ瘽鎴戣〃榪扮殑涓嶅ソ銆備婦涓緥瀛愶紝璁炬湁綾?A, B鏄疉鐨勫瓙綾伙紝B鏈変竴涓嚜宸辯殑鏂規硶 bMethod()銆傚湪浠g爜涓紝鎴戝厛new涓涓狟鐨勫疄渚媌錛岀劧鍚庡啀declare涓涓狝鐨勫彉閲廰,騫惰a鎸囧悜b(a = b)錛岃繖鏃訛紝灝界a錛宐鎸囧悜鍚屼竴涓璞★紝浣嗕綘鍙互b.bMethod()鍗翠笉鑳藉a.bMethod()銆?/li>
  3. 鏋氫婦綾誨瀷鍙互瀹氫箟abstract鏂規硶錛屼絾浣犲繀欏昏嚦灝戝畾涔変竴涓灇涓懼父閲忔潵瀹炵幇榪欎簺abstract鏂規硶錛屽惁鍒欏皢浼氫駭鐢熺紪璇戦敊璇?/li>
  4. 鐢?鍙互鐪嬪嚭錛屽畾涔塿alue-specific class body瀹為檯涓婂氨鏄疄鐜版灇涓劇被鍨嬩腑鐨刟bstract鏂規硶鎴栬卭verride鏋氫婦綾誨瀷縐嶅瓨鍦ㄧ殑鏂規硶銆?br />


Jafe 2007-09-09 15:29 鍙戣〃璇勮
]]>
Java Enumeration (鏋氫婦綾誨瀷) (3) -- 鑷畾涔夌被浣?class body)http://m.tkk7.com/JafeLee/archive/2007/09/08/143614.htmlJafeJafeSat, 08 Sep 2007 07:39:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/09/08/143614.htmlhttp://m.tkk7.com/JafeLee/comments/143614.htmlhttp://m.tkk7.com/JafeLee/archive/2007/09/08/143614.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/143614.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/143614.htmlpackage聽custom;
publicenum聽Prefix
{
聽聽聽聽
//聽These聽are聽the聽values聽of聽this聽enumerated聽type.
聽聽聽聽
//聽Each聽one聽is聽followed聽by聽constructor聽arguments聽in聽parentheses.
聽聽聽聽
//聽The聽values聽are聽separated聽from聽each聽other聽by聽commas,聽and聽the
聽聽聽聽
//聽list聽of聽values聽is聽terminated聽with聽a聽semicolon聽to聽separate聽it聽from
聽聽聽聽
//聽the聽class聽body聽that聽follows.
聽聽聽聽MILLI("m",聽.001),聽
聽聽聽聽CENTI(
"c",聽.01),聽
聽聽聽聽DECI(
"d"),聽
聽聽聽聽DECA(
"D",聽10.0),聽
聽聽聽聽HECTA(
"h",聽100.0),聽
聽聽聽聽KILO(
"k",聽1000.0);聽聽//聽Note聽semicolon

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
//聽semicolon

聽聽聽聽
//聽This聽is聽the聽constructor聽invoked聽for聽each聽value聽above.
聽聽聽聽private聽Prefix(String聽abbrev,聽double聽multiplier)
聽聽聽聽{
聽聽聽聽聽聽聽聽
this.abbrev聽=聽abbrev;
聽聽聽聽聽聽聽聽
this.multiplier聽=聽multiplier;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
//Another聽constructor
聽聽聽聽private聽Prefix(String聽abbrev)
聽聽聽聽{
聽聽聽聽聽聽聽聽
this.abbrev聽=聽abbrev;
聽聽聽聽聽聽聽聽
this.multiplier聽=聽.1;
聽聽聽聽}
聽聽聽聽
聽聽聽聽
//聽These聽are聽the聽private聽fields聽set聽by聽the聽constructor
聽聽聽聽private聽String聽abbrev;
聽聽聽聽
privatedouble聽multiplier;

聽聽聽聽
//聽These聽are聽accessor聽methods聽for聽the聽fields.聽They聽are聽instance聽methods
聽聽聽聽
//聽of聽each聽value聽of聽the聽enumerated聽type.
聽聽聽聽public聽String聽abbrev()
聽聽聽聽{
聽聽聽聽聽聽聽聽
return聽abbrev;
聽聽聽聽}

聽聽聽聽
publicdouble聽multiplier()
聽聽聽聽{
聽聽聽聽聽聽聽聽
return聽multiplier;
聽聽聽聽}
}
闇娉ㄦ剰錛屼竴涓灇涓劇被鍨嬪彲浠ユ湁澶氫釜鏋勯犲櫒銆?br />


Jafe 2007-09-08 15:39 鍙戣〃璇勮
]]>
Java Enumeration (鏋氫婦綾誨瀷) (2) -- switch璇彞http://m.tkk7.com/JafeLee/archive/2007/09/08/143609.htmlJafeJafeSat, 08 Sep 2007 06:43:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/09/08/143609.htmlhttp://m.tkk7.com/JafeLee/comments/143609.htmlhttp://m.tkk7.com/JafeLee/archive/2007/09/08/143609.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/143609.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/143609.htmlpackage聽other;
import聽basic.Day;
publicclass聽SwitchTest
{
聽聽聽聽
publicstaticvoid聽main(String聽[]聽args)
聽聽聽聽{
聽聽聽聽聽聽聽聽
int聽FRIDAY聽=5;
聽聽聽聽聽聽聽聽System.out.println(FRIDAY);
聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽Day聽today聽
=聽Day.SATURDAY;
聽聽聽聽聽聽聽聽
switch(today)
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽
case聽FRIDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽SATURDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽SUNDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽MONDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽TUESDAT:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽WEDNESDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
case聽THURSDAY:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Today聽is聽"+聽today.toString().toLowerCase());
聽聽聽聽聽聽聽聽聽聽聽聽
break;
聽聽聽聽聽聽聽聽
default:
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"otherday");
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}
娉ㄦ剰鍦╟ase鏍囩涓紝Day涓嶅嚭鐜幫紝鍗砪ase Day.FRIDAY鏄笉鍚堟硶鐨勩傝屽湪鍏朵粬鍦版柟鍑虹幇鏃跺垯蹇呴』鐢―ay.FRIDAY


Jafe 2007-09-08 14:43 鍙戣〃璇勮
]]>
Java Enumeration (鏋氫婦綾誨瀷) (1) -- 鍩烘湰姒傚康http://m.tkk7.com/JafeLee/archive/2007/09/08/143578.htmlJafeJafeSat, 08 Sep 2007 06:13:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/09/08/143578.htmlhttp://m.tkk7.com/JafeLee/comments/143578.htmlhttp://m.tkk7.com/JafeLee/archive/2007/09/08/143578.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/143578.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/143578.htmlJava 5.0鏂板紩榪涗簡涓縐嶇被鍨嬶細鏋氫婦綾誨瀷銆傛槰鏅氱湅浜嗕竴涓嬶紝璇硶榪樻槸姣旇緝澶嶆潅鐨勶紝鑷沖皯姣擟鐨勬灇涓捐澶嶆潅鐨勫緢澶氾紝涓嶈繃鍔熻兘涔熷己澶т簡寰堝銆傚叿浣撹娉曡鍙傝 JLS 8.9
1銆佸畾涔変竴涓姛鑳界畝鍗曠殑鏋氫婦綾誨瀷錛屾洿瀹氫箟涓涓畝鍗曠殑綾誨緢鐩鎬技錛屼緥濡?/font>
package 聽basic;
public enum 聽Day
{
聽聽聽聽MONDAY,聽TUESDAT,聽WEDNESDAY,聽THURSDAY,聽FRIDAY,聽SATURDAY,聽SUNDAY
}
  • 璺熺被瀹氫箟涓鏍鳳紝鏋氫婦綾誨瀷鍙互鍗曠嫭鏀懼湪涓涓枃浠墮噷錛屽綋涓涓灇涓劇被鍨嬬敤public淇グ鏃訛紝瀹冨鍏朵粬鍖呭彲瑙侊紝鍚﹀垯鍙鍚屼竴涓寘涓殑綾誨彲瑙侊紝榪欏拰綾誨畾涔夋槸涓鏍風殑銆?/font>
  • 鏍囪瘑絎?MONDAY, TUESDAY絳夊氨縐頒負鏋氫婦甯擱噺錛坋numeration constants錛?/font>
  • 姣忎竴涓灇涓懼父閲忚闅愬紡鐨勫0鏄庢垚Day鐨勪竴涓猵ublic銆乻tatic鎴愬憳錛岃屼笖鍏剁被鍨嬩負Day錛屼害灝辨槸璇磋繖浜涘父閲忔槸self-typed鐨?br />
2銆佷笅闈㈢殑瀹氫箟涔熸槸鍚堟硶鐨勶細
package聽basic;

publicenum聽Day
{
聽聽聽聽MONDAY,聽TUESDAT,聽WEDNESDAY,聽THURSDAY,聽FRIDAY,聽SATURDAY,聽SUNDAY,
}
鎴?br />
package聽basic;

publicenum聽Day
{
聽聽聽聽MONDAY,聽TUESDAT,聽WEDNESDAY,聽THURSDAY,聽FRIDAY,聽SATURDAY,聽SUNDAY,;
}
鎴?br />
package聽basic;

publicenum聽Day
{
聽聽聽聽MONDAY,聽TUESDAT,聽WEDNESDAY,聽THURSDAY,聽FRIDAY,聽SATURDAY,聽SUNDAY;
}
浣嗘槸褰撴灇涓劇被鍨嬫湁鍏朵粬瀹氫箟鏃訛紝鍒欏垎鍙?鏄繀欏葷殑
3銆佸0鏄庛佷嬌鐢ㄤ竴涓灇涓劇被鍨嬶細
錛?錛夊湪鍚屼竴涓寘涓細

BasicMainClass.java

錛?錛夊湪涓嶅悓鍖呬腑錛?br />
OtherMainClass.java

4銆佹灇涓劇被鍨嬬殑鎬ц川錛氾紙鎽樿嚜o'relly 鍑虹増鐨?Java in A Nutshell 5th)

  • Enumerated types have no public constructor. The only instances of an enumerated type are those declared by the enum.

  • Enums are not Cloneable, so copies of the existing instances cannot be created.

  • Enums implement java.io.Serializable so they can be serialized, but the Java serialization mechanism handles them specially to ensure that no new instances are ever created.

  • Instances of an enumerated type are immutable: each enum value retains its identity. (We'll see later in this chapter that you can add your own fields and methods to an enumerated type, which means that you can create enumerated values that have mutable portions. This is not recommended, but does not affect the basic identity of each value.)

  • Instances of an enumerated type are stored in public static final fields of the type itself. Because these fields are final, they cannot be overwritten with inappropriate values: you can't assign the DownloadStatus.ERROR value to the DownloadStatus.DONE field, for example.

  • By convention, the values of enumerated types are written using all capital letters, just as other static final fields are.

  • Because there is a strictly limited set of distinct enumerated values, it is always safe to compare enum values using the = = operator instead of calling the equals() method.

  • Enumerated types do have a working equals( ) method, however. The method uses = =finalso that it cannot be overridden. This working equals( ) method allows enumerated values to be used as members of collections such as Set, List, and Map. internally and is

  • Enumerated types have a working hashCode() method consistent with their equals( )equals(), hashCode( ) is final. It allows enumerated values to be used with classes like java.util.HashMap. method. Like

  • Enumerated types implement java.lang.Comparable, and the compareTo() method orders enumerated values in the order in which they appear in the enum declaration.

  • Enumerated types include a working toString( ) method that returns the name of the enumerated value. For example, DownloadStatus.DONE.toString( ) returns the string "DONE" by default. This method is not final, and enum types can provide a custom implementation if they choose.

  • Enumerated types provide a static valueOf( ) method that does the opposite of the default
    toString( ) method. For example, DownloadStatus.valueOf("DONE") would return DownloadStatus.DONE.

  • Enumerated types define a final instance method namedordinal()that returns an integer for each enumerated value. The ordinal of an enumerated value represents its position (starting at zero) in the list of value names in the enum declaration. You do not typically need to use the ordinal( ) method, but it is used by a number of enum-related facilities, as described later in the chapter.

  • Each enumerated type defines a static method named values( ) that returns an array of enumerated values of that type. This array contains the complete set of values, in the order they were declared, and is useful for iterating through the complete set of possible values. Because arrays are mutable, the values( ) method always returns a newly created and initialized array.

  • Enumerated types are subclasses of java.lang.Enum, which is new in Java 5.0. (Enum is not itself an enumerated type.) You cannot produce an enumerated type by manually extending the Enum class, and it is a compilation error to attempt this. The only way to define an enumerated type is with the enum keyword.

  • It is not possible to extend an enumerated type. Enumerated types are effectively final, but the final keyword is neither required nor permitted in their declarations. Because enums are effectively final, they may not be abstract.

  • Like classes, enumerated types may implement one or more interfaces.聽




Jafe 2007-09-08 14:13 鍙戣〃璇勮
]]>
Java 鍗曞厓嫻嬭瘯http://m.tkk7.com/JafeLee/archive/2007/08/22/138699.htmlJafeJafeWed, 22 Aug 2007 13:00:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/08/22/138699.htmlhttp://m.tkk7.com/JafeLee/comments/138699.htmlhttp://m.tkk7.com/JafeLee/archive/2007/08/22/138699.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/138699.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/138699.html
1銆佸崟鍏冩祴璇曞埄鍣?JUnit 4
http://www.ibm.com/developerworks/cn/java/j-lo-junit4/

2銆丣Unit 4鎶㈠厛鐪?br />http://www.ibm.com/developerworks/cn/java/j-junit4.html

3銆佹繁鍏ユ帰绱?JUnit4錛堣繖涓技涔庤鍏堟敞鍐岀殑錛?br />http://www.ibm.com/developerworks/cn/edu/j-dw-java-junit4.html

4銆?font size="3">TestNG 浣?Java 鍗曞厓嫻嬭瘯杞昏屾槗涓?br />http://www.ibm.com/developerworks/cn/java/j-testng/

5銆?/font>榪芥眰浠g爜璐ㄩ噺: JUnit 4 涓?TestNG 鐨勫姣?br />http://www.ibm.com/developerworks/cn/java/j-cq08296/



Jafe 2007-08-22 21:00 鍙戣〃璇勮
]]>
Java鐐規淮 (3)http://m.tkk7.com/JafeLee/archive/2007/07/23/131890.htmlJafeJafeMon, 23 Jul 2007 07:47:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/07/23/131890.htmlhttp://m.tkk7.com/JafeLee/comments/131890.htmlhttp://m.tkk7.com/JafeLee/archive/2007/07/23/131890.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/131890.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/131890.htmlawtevent.JPG

2銆佸父鐢ˋWT浜嬩歡綾誨瀷鍒楄〃
ActionEvent聽聽 聽 KeyEvent
AdjustmentEvent 聽聽聽 MouseEvent
FocusEvent 聽聽聽 MouseWheelEvent
ItemEvent 聽聽聽 WindowEvent


鐢ㄤ簬鐩戝惉榪欎簺浜嬩歡鐨勬帴鍙o細
ActionListener                  MouseMotionListener
AdjustmentListener MouseWheelListener
FocusListener WindowListener
ItemListener WindowFocusListener
KeyListener WindowStateListener
MouseListener


甯哥敤鐨勯傞厤鍣ㄧ被錛?br />FocusAdapter MouseMotionAdapter
KeyAdapter WindowAdapter
MouseAdapter


3銆佷簨浠剁洃鍚師鐞嗭細
鎺ユ敹浜嬩歡鐨勭被蹇呴』瀹炵幇鐩戝惉鎺ュ彛錛岃繖涓被瑕佺敤浜嬩歡婧愭敞鍐岋紝鐒跺悗錛屾帴鍙楁墍闇瑕佺殑浜嬩歡瀵硅薄錛屽茍閫氳繃鐩戝惉鍣ㄦ帴鍙d腑鐨勬柟娉曞浜嬩歡浣滃嚭鐩稿簲鐨勫鐞?br />
4銆佹墍鏈堿WT浜嬩歡婧愰兘鏀寔澶氱偣浼犻侊紙multicast)妯″瀷錛屽嵆鍚屼竴涓簨浠跺彲浠ュ彂閫佺粰澶氫釜鐩戝惉鍣ㄥ璞°傚綋鏃禔PI涓嶈兘淇濊瘉涓涓粰瀹氫簨浠舵簮娉ㄥ唽鐨勪竴緇勭洃鍚櫒浼犻佷簨浠剁殑嬈″簭錛屽洜姝や笉瑕佺紪鍐欎緷璧栦紶閫佹搴忕殑紼嬪簭閫昏緫銆?br />

Jafe 2007-07-23 15:47 鍙戣〃璇勮
]]>
Java緇ф壙http://m.tkk7.com/JafeLee/archive/2007/07/22/131188.htmlJafeJafeSun, 22 Jul 2007 08:40:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/07/22/131188.htmlhttp://m.tkk7.com/JafeLee/comments/131188.htmlhttp://m.tkk7.com/JafeLee/archive/2007/07/22/131188.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/131188.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/131188.html1銆佸叧閿瓧super鏈変袱涓敤閫旓細涓鏄皟鐢ㄨ秴綾葷殑鏂規硶錛岃屾槸璋冪敤瓚呯被鐨勬瀯閫犲櫒銆?br /> super涓嶆槸瀵逛竴涓璞$殑寮曠敤錛屼笉鑳藉皢super璧嬬粰鍙︿竴涓璞″彉閲忥紝瀹冨彧鏄竴涓寚紺虹紪璇戝櫒璋冪敤瓚呯被鏂規硶鐨勭壒鏈夊叧閿瓧銆俿uper鍦ㄦ瀯閫犲櫒涓殑浣滅敤錛?br />
    public 聽Manager(String聽n,聽 double 聽s,聽 int 聽year,聽 int 聽month,聽 int 聽day)聽聽聽聽
    {聽聽聽聽聽聽
    聽聽
    super (n,聽s,聽year,聽month,聽day);聽聽聽聽
    聽聽bonus聽
    = 0 ;聽聽聽聽
    }聽聽聽聽

鐢變簬鏋勯犲櫒涓嶈兘鑼冨洿Employee綾葷殑縐佹湁鍩燂紙鍏蜂綋渚嬪瓙瑙佹湰鏂囨渶鍚庨潰PersonTest.java錛夛紝鎵浠ュ繀欏誨埄鐢‥mployee綾葷殑鏋勯犲櫒瀵硅繖閮ㄥ垎縐佹湁鍩熻繘琛屽垵濮嬪寲瀛?/font> 錛屾垜浠彲浠ラ氳繃super瀹炵幇瀵硅秴綾繪瀯閫犲櫒鐨勮皟鐢ㄣ?font color="#ff0000">浣跨敤super璋冪敤鏋勯犲櫒鐨勮鍙ュ繀欏繪槸 綾繪瀯閫犲櫒鐨勭涓鏉¤鍙?/font>銆傚鏋滀箣綾葷殑鏋勯犲櫒娌℃湁鏄劇ず鐨勮皟鐢ㄨ秴綾葷殑鏋勯犲櫒錛岃繖灝嗚嚜鍔ㄨ皟鐢ㄨ秴綾婚粯璁わ紙娌℃湁鍙傛暟錛夌殑鏋勯犲櫒銆傚鏋滆秴綾繪病鏈変笉甯﹀弬鏁扮殑鏋勯犲櫒錛屽茍涓斿湪瀛愮被鐨勬瀯閫犲櫒涓病鏈夋樉紺哄湴璋冪敤瓚呯被鐨勫叾瀹冩瀯閫犲櫒錛屽垯Java緙栬瘧鍣ㄥ皢鎶ュ憡閿欒錛岃繖涓鍒欏涓巃bstract base class 涔熸槸鎴愮珛鐨勩?br />
2銆佸叧閿瓧this鏈変袱涓敤閫旓細涓鏄紩鐢ㄩ殣寮忓弬鏁幫紝浜屾槸璋冪敤璇ョ被鐨勫叾瀹冪殑鏋勯犲櫒銆傚湪璋冪敤鏋勯犲櫒鏃跺拰super寰堢浉浼鹼紝閮藉彧鑳戒綔涓哄彟涓涓瀯閫犲櫒鐨勭涓鏉¤鍙ュ嚭鐜般?br />
3銆佸鎬併傚厛鐪嬩緥瀛愶細
Manager聽boss聽=new聽Manager();
Employee聽[]聽staff聽
=new聽Employee[3];
staff[
0]聽=聽boss;
鍦ㄨ繖涓緥瀛愪腑錛屽彉閲弒taff[0]鍜宐oss寮曠敤鍚屼竴涓璞?浣嗙紪璇戝櫒灝唖taff[0]鐪嬪緟鎴怑mployee瀵硅薄.榪欐剰鍛崇潃鍙互榪欐牱璋冪敤:
boss.setBonus(5000);
浣嗕笉鑳借繖鏍瘋皟鐢?br />staff[0].setBonus(5000);//error錛岃繖鏍蜂細寮曡搗涓涓紪璇戦敊璇?br />榪欐槸鍥犱負staff[0]澹版槑鐨勭被鍨嬫槸Employee錛岃宻etBonus涓嶆槸Empoyee綾葷殑鏂規硶銆?br />
4銆佸姩鎬佺粦瀹氾細
  • 鏂規硶鐨勫悕瀛楀拰鍙傛暟鍒楄〃琚О涓烘柟娉曠殑絳懼悕錛坰ignature).濡傛灉鍦ㄥ瓙綾諱腑瀹氫箟浜嗕竴涓笌瓚呯被絳懼悕鐩稿悓鐨勬柟娉曪紝閭d箞瀛愮被涓殑榪欎釜鏂規硶灝辮鐩栦簡瓚呯被涓殑榪欎釜鍚岀鍚嶇殑鏂規硶銆備絾鏄紝榪斿洖綾誨瀷涓嶆槸絳懼悕鐨勪竴閮ㄥ垎錛屽洜姝ゅ湪瑕嗙洊鏂規硶鐨勬椂鍊欙紝涓瀹氳淇濊瘉榪斿洖綾誨瀷鐨勫吋瀹規с傚湪JDK 5.0浠ュ墠鐨勭増鏈腑錛岃姹傝繑鍥炵被鍨嬪繀欏繪槸涓鏍風殑銆傝岀幇鍦ㄥ厑璁稿瓙綾誨皢瑕嗙洊鏂規硶榪斿洖綾誨瀷瀹氫箟涓哄師榪斿洖綾誨瀷鐨勫瓙綾誨瀷銆備緥濡傦紝鍋囪Employee綾繪湁錛?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">public聽Employee聽getBuddy(){}鍦ㄥ悗闈㈢殑瀛愮被Manager涓紝鍙互鎸夌収濡備笅鎵紺虹殑鏂規硶瑕嗙洊榪欎釜鏂規硶錛?div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;">public聽Manager聽getBuddy(){}聽//OK聽in聽JDK聽5.0
  • 濡傛灉鏂規硶鏄痯rivate, static, final鎴栬呮槸鏋勯犲櫒錛岄偅涔堢紪璇戝櫒灝嗗彲浠ュ噯紜湴鐭ラ亾搴旇璋冪敤閭d釜鏂規硶銆傛垜浠皢榪欑璋冪敤鏂瑰紡縐頒負闈欐佺粦瀹氥備絾鏄紝瀛愮被涓嶈兘緇ф壙鐖剁被private 錛堟柟娉?鏇磋皥涓嶄笂瑕嗙洊錛変笉鑳借鐩杅inal淇グ鐨勬柟娉曪紝浣嗗彲涓瑕嗙洊static鏂規硶
  • 瑕嗙洊涓涓柟娉曠殑鏃跺欙紝瀛愮被鏂規硶涓嶈兘浣庝簬瓚呯被鏂規硶鐨勫彲瑙佹с傜壒鍒槸濡傛灉瓚呯被寰楁柟娉曟槸public錛岄偅涔堝瓙綾繪柟娉曚竴瀹氳澹版槑涓簆ublic銆?br />


Jafe 2007-07-22 16:40 鍙戣〃璇勮
]]>
Java 鐐規淮 (2)http://m.tkk7.com/JafeLee/archive/2007/07/21/120165.htmlJafeJafeSat, 21 Jul 2007 01:55:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/07/21/120165.htmlhttp://m.tkk7.com/JafeLee/comments/120165.htmlhttp://m.tkk7.com/JafeLee/archive/2007/07/21/120165.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/120165.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/120165.html錛?錛?浣跨敤 * 涓嬈″彧鑳絠mport 涓涓猵ackage鐨勭被錛屼緥濡傛兂瑕?import 鍖卝ava.util涓唴瀹逛笉鑳界敤 import java.*.*; 涔熶笉鑳戒紒鍥鵑氳繃榪欑鏂瑰紡錛?font color="#0000ff">import java.*; util.Date date = new Date();鏉ュ紩鐢?br />
錛?錛塻tatic imports: 浠嶫DK 5.0寮濮嬶紝鍙互鐢╯tatic鏂規硶鏉mport 鏌愪釜綾葷殑闈欐佹柟娉曞拰闈欐佸父閲忋備緥濡傦細

ImportTest.java

static imports 鐨勫ソ澶勶細渚嬪錛?/font>sqrt(pow(x, 2) + pow(y, 2))
姣?font color="#0000ff">Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
聽 錛浡?font color="#0000ff"> if (d.get(DAY_OF_WEEK) == MONDAY)
姣?if (d.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) 鐪嬭搗鏉ヨ鏁存磥錛屽彲璇繪т篃涓濇涓嶄細鍙楀獎鍝崀~

2銆佸潡浣滅敤鍩燂細錛堝弬鑰冭祫鏂欙細銆奐ava2 鏍稿績鎶鏈嬶級
錛?錛夊潡錛堝嵆絎﹀悎璇彞錛夋槸鎸囩敱涓瀵硅姳鎷彿鎷搗鏉ョ殑鑻ュ共鏉$畝鍗曠殑Java璇彞銆傚潡紜畾浜嗗彉閲忕殑浣滅敤鍩熴備竴涓潡鍙互宓屽鍦ㄥ彟涓涓潡涓備緥濡?br />
TestBlock.java
娉ㄦ剰k鐨勪綔鐢ㄥ煙錛屽湪鑺辨嫭鍙峰鏄笉鑳藉啀寮曠敤k鐨勩?br />錛?錛変笉鑳藉湪宓屽鐨勪袱涓潡涓0鏄庡悓鍚嶅彉閲忋備緥濡備笅闈㈢殑浠g爜緙栬瘧鏃舵槸閫氫笉榪囩殑錛?br />
TestBlock.java

浣嗘槸榪欐牱鏄彲浠ョ殑錛?br />
TestBlock.java

3銆佷嬌鐢ㄥ唴閮ㄧ被(inner class)鐨勫姩鏈猴細
4銆佸彧鏈夊唴閮ㄧ被鍙互鏄鏈夌被錛屽父瑙勭被鍙兘鍏鋒湁鍖呯殑鍙鎬ф垨鍏湁鐨勫彲瑙佹?br />
5銆丣Frame 涓嶫Pane綾葷殑緇ф壙灞傛緇撴瀯
jframe.JPG

6銆佹湁鏃跺橨Frame紼嬪簭閫鍑烘椂涓轟粈涔堣璋冪敤setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)?
榪欐槸鍥犱負鍦ㄥ寘鍚涓▼搴忔鏋剁殑紼嬪簭涓紝涓嶈兘鍥犱負鐢ㄦ埛鍏抽棴浜嗗叾涓竴涓鏋跺氨璁╃▼搴忛鍑恒傚湪榛樿鎯呭喌涓嬬敤鎴峰叧闂獥鍙f椂鍙槸灝嗘鏋墮殣钘忎簡璧鋒潵錛岃岀▼搴忓茍娌℃湁緇堟銆?br />
7銆佸皝瑁呬簡鐢ㄦ埛緋葷粺鐨勫悇涓厓绱犵殑棰滆壊鐨凷ystemColor綾諱腑鐨勭郴緇熼鑹插拰瀹冧滑鐨勫惈涔夛細

System Colors

desktop

Background color of desktop

activeCaption

Background color for captions

activeCaptionText

Text color for captions

activeCaptionBorder

Border color for caption text

inactiveCaption

Background color for inactive captions

inactiveCaptionText

Text color for inactive captions

inactiveCaptionBorder

Border color for inactive captions

window

Background for windows

windowBorder

Color of window border frame

windowText

Text color inside windows

menu

Background for menus

menuText

Text color for menus

text

Background color for text

textText

Text color for text

textInactiveText

Text color for inactive controls

textHighlight

Background color for highlighted text

textHighlightText

Text color for highlighted text

control

Background color for controls

controlText

Text color for controls

controlLtHighlight

Light highlight color for controls

controlHighlight

Highlight color for controls

controlShadow

Shadow color for controls

controlDkShadow

Dark shadow color for controls

scrollbar

Background color for scrollbars

info

Background color for spot-help text

infoText

Text color for spot-help text



Jafe 2007-07-21 09:55 鍙戣〃璇勮
]]>Java Interfacehttp://m.tkk7.com/JafeLee/archive/2007/05/26/119852.htmlJafeJafeFri, 25 May 2007 16:16:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/05/26/119852.htmlhttp://m.tkk7.com/JafeLee/comments/119852.htmlhttp://m.tkk7.com/JafeLee/archive/2007/05/26/119852.html#Feedback2http://m.tkk7.com/JafeLee/comments/commentRss/119852.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/119852.html
2銆佹帴鍙d笉鑳藉疄鐜版柟娉曪紙implement method),鍙兘澹版槑銆傛帴鍙e彲浠ュ彧瀹氫箟甯擱噺浣嗕笉澹版槑浠諱綍鏂規硶銆?br />
3銆両nterface涓嶈兘鏈夊疄渚嬪煙錛坕nstance fields)鎴栭潤鎬佹柟娉曪紙static method),浣嗗彲浠ュ畾涔夊父閲?define constants),甯擱噺鑷姩璁句負public static final錛屽彲浠ラ氳繃綾誨懡鐩存帴寮曠敤甯擱噺錛屼緥濡?br />
ImplementClass.z
鍙互閫氳繃鎺ュ彛鍛藉拰甯擱噺鍚嶇洿鎺ヨ闂父閲忥細
FirstInterface.z

4銆佷竴涓?font color="#000000">闈炴娊璞?/font>綾?font color="#ff0000">錛堟敞鎰忔槸闈炴娊璞$被錛侊級瀹炵幇涓涓帴鍙f椂錛屽繀欏誨疄鐜版帴鍙g殑鎵鏈夋柟娉曪紝鎶借薄綾誨垯涓嶅繀瀹炵幇鎵鏈夋柟娉曘?br />
5銆佷笉鑳戒嬌鐢╪ew鎿嶄綔絎﹀疄渚嬪寲涓涓帴鍙o紝浣嗗彲浠ュ0鏄庝竴涓帴鍙e彉閲忥紝璇ュ彉閲忓繀欏誨紩鐢紙refer to)涓涓疄鐜拌鎺ュ彛鐨勭被鐨勫璞°傚彲浠ヤ嬌鐢?instanceof 媯鏌ヤ竴涓璞℃槸鍚﹀疄鐜頒簡鏌愪釜鐗瑰畾鐨勬帴鍙c備緥濡傦細
if(anObject聽instanceof聽Comparable){}


6銆佹帴鍙e彲浠ヨ鍙︿竴涓帴鍙g戶鎵匡紙浣嗘槸final濂藉儚涓嶈兘淇グinterface錛岀紪璇戦氫笉榪囷紝浠ュ悗鎱㈡參鐮旂┒~~)

7銆佹爣璁版帴鍙o紙tagging interface, marker interface)娌℃湁鏂規硶錛屼嬌鐢ㄥ畠鐨勫敮涓鐩殑鏄彲浠ョ敤instanceof 榪涜綾誨瀷媯鏌ワ紙Horstmann璇翠簡錛屼笉榧撳姳鐢ㄨ繖縐嶆妧鏈?^_^錛?br />
8銆?font size="3">鏂規硶鐨勫悕瀛楀拰鍙傛暟鍒楄〃琚О涓烘柟娉曠殑絳懼悕錛坰ignature)錛屽疄鐜頒竴涓帴鍙d互涓虹潃瑕佺敤瀹屽叏鐩稿悓鐨勭鍚嶅疄鐜版瘡涓柟娉曘傚洜姝ゅ疄鐜版帴鍙f柟娉曟椂錛屼竴瀹氳淇濊瘉榪斿洖綾誨瀷鐨勫吋瀹規с?/font>鍏佽瀹炵幇綾葷殑瀹炵幇鏂規硶榪斿洖綾誨瀷瀹氫箟涓哄師榪斿洖綾誨瀷鐨勫瓙綾誨瀷銆傝繖涓窡緇ф壙涓瓙綾昏鐩栫埗綾繪柟娉曞緢鐩鎬技銆?br />
8銆佷緥瀛愶細
FirstInterface.java

SecondInterface.java

ImplementClass.java

Main.java

榪愯緇撴灉錛?br />20
21
22
I love you!
I love you!
9銆佸尶鍚嶅唴閮ㄧ被(anonymous inner class):
娉ㄦ剰涓涓壒鍒殑渚嬪瓙
AnonymousInnerClass.java
鑰宩ava.util.Comparator鐨勫畾涔変負
Comparator.java
鎴戞暍寮濮嬬湅瑙夊緱濂囨紝濂藉儚鍦ㄥ尶鍚嶅唴閮ㄧ被涓病鏈夊疄鐜版柟娉昩oolean equals(Object obj);鍚庢潵浠旂粏涓鎯籌紝鍏跺疄鎵鏈夌殑綾婚兘鏄疧bject鐨勫瓙綾伙紝鑰孫bject姝eソ鏈夎鏂規硶鐨勫疄鐜幫紝鎵浠ワ紝鍗充嬌娌℃湁瀹炵幇璇ユ柟娉曚篃鏄悎娉曠殑銆?br />

Jafe 2007-05-26 00:16 鍙戣〃璇勮
]]>
Java 縐諱綅鎿嶄綔http://m.tkk7.com/JafeLee/archive/2007/05/22/119177.htmlJafeJafeTue, 22 May 2007 09:17:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/05/22/119177.htmlhttp://m.tkk7.com/JafeLee/comments/119177.htmlhttp://m.tkk7.com/JafeLee/archive/2007/05/22/119177.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/119177.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/119177.html錛?錛?lt;< : (left-shift), 鏈浣庝綅琛?
錛?錛?gt;> : 錛坰igned right-shift), 鍙崇Щ榪囩▼浣跨敤絎﹀彿浣嶆墿灞曪紙sign extension)錛屽嵆濡傛灉絎﹀彿涓轟負1鍒欓珮浣嶈ˉ1錛屄?鏄?鍒欒ˉ0錛屼篃灝辨槸閫昏緫鍙崇Щ
錛?錛?gt;>> : (unsigned right-shit),鍙崇Щ榪囩▼浣跨敤闆舵墿灞曪紙zero extension),鍗蟲渶楂樹綅涓寰嬭ˉ0錛屼篃灝辨槸綆楁湳鍙崇Щ
錛?錛? 縐諱綅鎿嶄綔鐨勬暟鎹被鍨嬪彲浠ユ槸byte, char, short, int, long鍨嬶紝浣嗘槸瀵筨yte, char, short榪涜鎿嶄綔鏃朵細鍏堟妸瀹冧滑鍙樻垚涓涓猧nt鍨嬶紝鏈鍚庡緱鍒頒竴涓猧nt鍨嬬殑緇撴灉錛屽long鍨嬫搷浣滄椂寰楀埌涓涓猯ong鍨嬬粨鏋滐紝涓嶅彲浠ュboolean鍨嬭繘 琛屾搷浣溿?br />錛?錛夌Щ浣嶆搷浣滅鍙互鍜岋紳鍚堝茍璧鋒潵錛屽嵆 <<= 銆?>>= 鍜?>>>=銆備緥濡?a >>= 2; 琛ㄧず灝哸鍙崇Щ涓や綅鍚庣殑鍊奸噸鏂拌祴緇檃銆傚綋鏃跺湪浣跨敤榪欎笁涓搷浣滅瀵?byte, char, short鍨嬫暟鎹繘琛屾搷浣滄椂瑕佹敞鎰忥紝渚嬪鏈変竴涓嬩唬鐮佺墖孌碉細
publicclass聽ShiftTest
{
聽聽聽聽
publicstaticvoid聽main(String聽[]聽args)
聽聽聽聽{
聽聽聽聽聽聽聽聽
byte聽a;
聽聽聽聽聽聽聽聽
byte聽b;
聽聽聽聽聽聽聽聽
byte聽c;
聽聽聽聽聽聽聽聽a聽
=127;
聽聽聽聽聽聽聽聽b聽
=127;
聽聽聽聽聽聽聽聽c聽
=127;
聽聽聽聽聽聽聽聽a聽
<<=2;
聽聽聽聽聽聽聽聽System.out.println(a);
聽聽聽聽聽聽聽聽System.out.println(b聽
<<=2);
聽聽聽聽聽聽聽聽System.out.println(c聽
<<2);
聽聽聽聽}
}
聽聽聽聽
榪愯緇撴灉鏄細
聽聽聽 聽聽聽 聽聽聽 -4
聽聽聽 聽聽 聽聽 聽 -4
聽聽聽 聽聽 聽聽 聽聽 508
榪? 璇存槑浜嗗湪鎿嶄綔a <<= 2 鎵ц榪囩▼鏄繖鏍風殑錛氬厛灝?byte鍨嬬殑鏁?127鍙樻垚int鍨嬶紝宸︾Щ2浣嶅緱鍒? 508錛岀劧鍚庢妸508璧嬬粰byte鍨嬪彉閲廰鏃跺彧鏄畝鍗曞湴"鎶樻柇"(truncate)寰楀埌鏁?4銆傜紪璇戞椂緙栬瘧鍣ㄤ笉浼氭彁紺轟綘鍙兘鎹熷け綺懼害錛堝疄闄呬笂鍦ㄦ湰渚嬩腑紜? 瀹炴槸鎹熷け綺懼害浜嗭級錛屼絾鏄鏋滀綘鎶奱 <<= 2鏀規垚 a = a << 2;緙栬瘧鍣ㄥ氨浼氭彁紺哄彲鑳芥崯澶辯簿搴︿簡銆?img src ="http://m.tkk7.com/JafeLee/aggbug/119177.html" width = "1" height = "1" />

Jafe 2007-05-22 17:17 鍙戣〃璇勮
]]>
Java 鐐規淮 (1)http://m.tkk7.com/JafeLee/archive/2007/05/21/118918.htmlJafeJafeMon, 21 May 2007 08:30:00 GMThttp://m.tkk7.com/JafeLee/archive/2007/05/21/118918.htmlhttp://m.tkk7.com/JafeLee/comments/118918.htmlhttp://m.tkk7.com/JafeLee/archive/2007/05/21/118918.html#Feedback0http://m.tkk7.com/JafeLee/comments/commentRss/118918.htmlhttp://m.tkk7.com/JafeLee/services/trackbacks/118918.html 1銆?/font>Java榪愮畻絎︿紭鍏堢駭錛?br />
Operator Precedence

Operators

Associativity

[] . () (method call)

Left to right

! ~ ++ -- + (unary) 鈥?/tt> (unary) () (cast) new

Right to left

* / %

Left to right

+ -

Left to right

<< >> >>>

Left to right

< <= > >= instanceof

Left to right

== !=

Left to right

&

Left to right

^

Left to right

|

Left to right

&&

Left to right

||

Left to right

?:

Right to left

= += -= *= /= %= &= |= ^= <<= >>= >>>=

Right to left


娉ㄦ剰錛?br />
  • && || ! 鐨勬搷浣滄暟鍙兘鐢ㄤ簬boolean 鎴?Boolean
  • &聽 | 鐨勬搷浣滄暟鏃㈠彲浠ョ敤浜巄oolean(Boolean)鎴栬呮暣褰?涓嶄粎浠呮槸int鍨嬶級錛屼絾涓や釜鎿嶄綔鏁扮殑綾誨瀷蹇呴』涓鑷?/li>
  • ~涓嶈兘鐢ㄤ簬boolean(Boolean)鍨嬶紝浣嗗彲浠ョ敤浜庢暣褰紝澶ф鏄負浜嗗拰 ! 鍖哄埆寮鏉ュ惂
  • & | 娌℃湁鐭礬璁$畻鐨?br />
2銆?/font>
Java Integer Types

Type

Storage Requirement

Range (Inclusive)

int

4 bytes

鈥?,147,483,648 to 2,147,483,647 (just over 2 billion)

short

2 bytes

鈥?2,768 to 32,767

long

8 bytes

鈥?,223,372,036,854,775,808 to 9,223,372,036,854,775,807

byte

1 byte

鈥?28 to 127

聽聽聽聽聽 char聽聽 聽聽 聽聽 聽聽 聽聽聽聽聽聽聽聽聽 聽 2 bytes聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽聽聽聽 0 to 65535

3銆?/font>

Floating-Point Types

Type

Storage Requirement

Range

float

4 bytes

approximately 鹵3.40282347E+38F (6鈥? significant decimal digits)

double

8 bytes

approximately 鹵1.79769313486231570E+308 (15 significant decimal digits)


4銆乫inal 瀹炰緥鍩燂紙final instance field)錛氬彲浠ュ皢瀹炰緥鍩熷畾涔変負final錛屾瀯寤哄璞℃椂蹇呴』鍒濆鍖栬繖鏍峰緱鍩燂紝涔熷氨鏄錛屽繀欏葷‘淇濆湪姣忎竴涓瀯閫犲櫒鎵ц涔嬪悗錛岃繖涓煙鐨勫艱璁劇疆銆備絾鏄紝闈欐佸父閲忓繀欏誨湪澹版槑鐨勫悓鏃朵篃琚垵濮嬪寲銆?br />
5銆乫or each 寰幆錛?br />for (variable : collection) statment
渚嬪錛歠or (int element : a)
聽聽聽 聽聽 聽聽 System.out.println(element);
璇ヤ唬鐮佺墖孌墊墦鍗版暟緇刟鐨勬瘡涓涓厓绱狅紝涓涓厓绱犲崰涓琛?br />
6銆佸悎娉曠殑Java鏍囪瘑絎︼細鍙互浠ヤ笅鍒掔嚎銆佸瓧姣嶆垨緹庡厓絎﹀彿$寮澶達紝鍚庨潰鍙互璺熶笅鍒掔嚎銆佹暟瀛椼佸瓧姣嶃佺編鍏冪鍙楓?.42浠ュ悗鐨刯ava鏍囪瘑絎︿篃鍙互鍖呭惈姹夊瓧錛屽寘鎷紑澶淬?br />

Jafe 2007-05-21 16:30 鍙戣〃璇勮
]]>
Java abstract 綾?/title><link>http://m.tkk7.com/JafeLee/archive/2007/05/20/118706.html</link><dc:creator>Jafe</dc:creator><author>Jafe</author><pubDate>Sun, 20 May 2007 10:27:00 GMT</pubDate><guid>http://m.tkk7.com/JafeLee/archive/2007/05/20/118706.html</guid><wfw:comment>http://m.tkk7.com/JafeLee/comments/118706.html</wfw:comment><comments>http://m.tkk7.com/JafeLee/archive/2007/05/20/118706.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://m.tkk7.com/JafeLee/comments/commentRss/118706.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/JafeLee/services/trackbacks/118706.html</trackback:ping><description><![CDATA[聽聽聽 <font size="3">铏界劧鎺ヨЕJava宸茬粡蹇竴騫翠簡錛屼篃緋葷粺鐨勫榪嘕ava璇硶錛屼笉榪囧緢澶氭蹇靛埌鐜板湪閮芥悶涓嶆竻妤氾紝鐜板湪鍐沖畾閲嶆柊鎶婅繖浜涙ā緋婄殑姒傚康閲嶆柊娓╀範涓閬嶏紝浠婂ぉ灝辯幇鎬葷粨涓涓嬫娊璞$被錛坅bstract class)銆?br /><br /> 1銆佷嬌鐢╝bstract綾葷殑鍔ㄦ満錛氬彲浠ュ弬鑰?<span id="fdx7fdx" class="v1">Cay聽S.聽Horstmann</span>, <span id="ljf9v9n" class="v1">Gary聽Cornel 鍐欑殑涔︺?strong>Core Java鈩?2 Volume I - Fundamentals, Seventh Edition</strong> 銆嬶紙欏轟究緗楀棪涓涓嬶紝璇ヤ功鏄伓瑙佽繃鏈濂界殑Java鍏ラ棬涔︼級 鈥淐lasses, Superclasses, and Subclasses 鈥濅竴鑺傦紝瀹氫箟涓涓猘bstract class鐨勬牸寮忔槸錛氫慨楗扮錛坧ublic, private, etc)+abstract+綾誨悕 <font color="#ff0000">鎴栬?/font> abstract + 淇グ絎?+ 綾誨悕銆?/span><br /><span id="h9r99fx" class="v1"></span><br /><span id="tzfzddt" class="v1">2銆佸鏋滀竴涓被鑷沖皯瀛樺湪涓涓娊璞℃柟娉?abstract method)錛屽垯瀹冭嚜韜繀欏誨0鏄庢垚涓涓娊璞$被銆備絾涓涓被鍙互琚0鏄庢垚涓涓娊璞$被鍗充嬌瀹冩病鏈変換浣曟娊璞℃柟娉曘傚0鏄庝竴涓猘bstrac</span>t method鐨勬牸寮忔槸錛?/font><font size="3"><span id="7j7r9rf" class="v1">淇グ絎︼紙public, private, etc)+abstract+榪斿洖綾誨瀷 + 鏂規硶鍚?<font color="#ff0000">鎴栬?/font> abstract + 淇グ絎?+ 榪斿洖綾誨瀷 + 鏂規硶鍚嶃?/span></font><br /><font size="3"><span id="7lj999f" class="v1"></span><br /><span id="jbv9b7h" class="v1">3銆佷竴涓娊璞$被鍙互鏈夋暟鎹煙鍜岄潪鎶借薄鏂規硶錛坈oncrete data and concrete methods)銆?/span><br /><span id="d9t9zb9" class="v1"></span><br /><span id="rr9lh9t" class="v1">4銆佸綋涓涓瓙綾葷戶鎵挎煇涓娊璞$被鏃訛紝瀹冨彲浠ユ湁涓や釜閫夋嫨錛?br />聽聽聽 (1)聽聽聽 閮ㄥ垎瀹炵幇鎴栧畬鍏ㄤ笉瀹炵幇鐖剁被鐨勬墍鏈夋娊璞℃柟娉曪紝浣嗘鏃跺瓙綾誨繀欏誨0鏄庝負鎶借薄綾匯?br />聽聽聽 (2)聽聽聽 瀹炵幇鐖剁被鎵鏈夌殑鎶借薄鏂規硶錛屾鏃朵箣綾諱笉姣斿0鏄庝負鎶借薄綾匯?br /><br />5銆佹娊璞$被涓嶈兘琚疄渚嬪寲錛坆e instantiated)錛屼絾鍙互瀹炰緥鍖栭潪鎶借薄瀛愮被錛坈oncrete subclass)銆?br />聽聽 鍙互澹版槑鎶借薄綾誨彉閲忥紝浣嗚鍙橀噺蹇呴』鎸囧悜涓涓潪鎶借薄瀛愮被</span><span id="trnhjrh" class="v1">.鐪嬩笅闈竴涓緥瀛愶細<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">聽聽聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.聽聽Person聽[]聽people聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Person[</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">];聽聽聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">.聽people[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Employee(<img src="http://m.tkk7.com/images/dot.gif" />);聽聽聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">.聽people[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Student(<img src="http://m.tkk7.com/images/dot.gif" />);聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">.聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(Person聽p聽:聽people)聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">.聽聽聽聽System.out.println(p.getName()聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽p.getDescription());聽聽<br /></span></div></span></font><span id="l99bftj" class="v1"><font size="3"><font size="3">娉ㄦ剰浠g爜涓殑涓涓皟鐢?p.getDescription().鍙兘鏈変漢浼氭媴蹇冭繖閲岃皟鐢ㄤ簡涓涓病瀹氫箟鐨勬柟娉曘備絾鏄紝 鐢變簬<font size="3">涓嶈兘鏋勯犳娊璞$被Person鐨勫璞★紝鎵浠姘歌繙涓嶄細璋冨姩Person瀵硅薄錛岃屾槸鍙細璋冪敤璇稿Employee鎴朣tudent榪?/font></font><font size="3">鏍風殑鍏蜂綋瀛愮被鏂規硶銆?/font></font><font color="#ff0000" size="3">娉ㄦ剰錛屽鏋滄病鏈夊畾涔塒erson涓娊璞℃柟娉昰etDescription()浣嗘槸閫氳繃p璋冪敤getDescription()鍒欎細浜х敓緙栬瘧閿欒錛岀紪璇戝櫒鍙厑璁歌皟鐢ㄥ湪綾諱腑澹版槑鐨勬柟娉曘?/font></span><font size="3"><br /></font><span id="phjl7x9" class="v1"><font size="3"><br />6銆佹憳鑷奀ore Java 2銆嬬殑涓涓緥瀛愶細</font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><img id="Code_Closed_Image_075958" onclick="this.style.display='none'; Code_Closed_Text_075958.style.display='none'; Code_Open_Image_075958.style.display='inline'; Code_Open_Text_075958.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ContractedBlock.gif" align="top" height="16" width="11" /><img id="Code_Open_Image_075958" style="display: none;" onclick="this.style.display='none'; Code_Open_Text_075958.style.display='none'; Code_Closed_Image_075958.style.display='inline'; Code_Closed_Text_075958.style.display='inline';" src="http://m.tkk7.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" height="16" width="11" /><span id="Code_Closed_Text_075958" style="border: 1px solid rgb(128, 128, 128); background-color: rgb(255, 255, 255);">PersonTest.java</span><span id="Code_Open_Text_075958" style="display: none;"><br /><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />聽聽聽</span><span style="color: rgb(128, 128, 128);">@version</span><span style="color: rgb(0, 128, 0);">聽1.01聽2004-02-21<br />聽聽聽</span><span style="color: rgb(128, 128, 128);">@author</span><span style="color: rgb(0, 128, 0);">聽Cay聽Horstmann<br /></span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br /><br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">聽java.text.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">聽java.util.</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">;<br /><br /></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽PersonTest<br />{聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽main(String[]聽args)<br />聽聽聽{聽聽<br />聽聽聽聽聽聽Person[]聽people聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Person[</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">];<br /><br />聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽fill聽the聽people聽array聽with聽Student聽and聽Employee聽objects</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽people[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Employee(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Harry聽Hacker</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">50000</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">1989</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">10</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽people[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Student(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Maria聽Morris</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">computer聽science</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /><br />聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽print聽out聽names聽and聽descriptions聽of聽all聽Person聽objects</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(Person聽p聽:聽people)<br />聽聽聽聽聽聽聽聽聽System.out.println(p.getName()聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽p.getDescription());<br />聽聽聽}<br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Person<br />{聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Person(String聽n)<br />聽聽聽{聽聽<br />聽聽聽聽聽聽name聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽n;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽String聽getDescription();<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽String聽getName()<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽name;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽String聽name;<br />}<br /><br /></span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Employee聽</span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);">聽Person<br />{聽聽<br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Employee(String聽n,聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽s,<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽year,聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽month,聽</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽day)<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">super</span><span style="color: rgb(0, 0, 0);">(n);<br />聽聽聽聽聽聽salary聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽s;<br />聽聽聽聽聽聽GregorianCalendar聽calendar聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽GregorianCalendar(year,聽month聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">,聽day);<br />聽聽聽聽聽聽hireDay聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽calendar.getTime();<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽getSalary()<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽salary;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Date聽getHireDay()<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽hireDay;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽String聽getDescription()<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽String.format(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">an聽employee聽with聽a聽salary聽of聽$%.2f</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽salary);<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽raiseSalary(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽byPercent)<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽raise聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽salary聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽byPercent聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">100</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽salary聽</span><span style="color: rgb(0, 0, 0);">+=</span><span style="color: rgb(0, 0, 0);">聽raise;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽salary;<br />聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽Date聽hireDay;<br />}<br /><br /><br /></span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Student聽</span><span style="color: rgb(0, 0, 255);">extends</span><span style="color: rgb(0, 0, 0);">聽Person<br />{聽聽<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">/**</span><span style="color: rgb(0, 128, 0);"><br />聽聽聽聽聽聽</span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);">聽n聽the聽student's聽name<br />聽聽聽聽聽聽</span><span style="color: rgb(128, 128, 128);">@param</span><span style="color: rgb(0, 128, 0);">聽m聽the聽student's聽major<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Student(String聽n,聽String聽m)<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽pass聽n聽to聽superclass聽constructor</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">super</span><span style="color: rgb(0, 0, 0);">(n);<br />聽聽聽聽聽聽major聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽m;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽String聽getDescription()<br />聽聽聽{聽聽<br />聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">a聽student聽majoring聽in聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽major;<br />聽聽聽}<br /><br />聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽String聽major;<br />}<br /></span></span></div><br />鍙傝冭祫鏂欙細<br /><br /></span><p style="color: rgb(96, 24, 255);"><span id="9xnfzpp" class="v1"><span style="font-weight: bold; font-size: 18pt;">Core Java 2 Volume I - Fundamentals, Seventh Edition</span></span></p><p>by Cay S. Horstman, Gary Cornell<br /></p><span id="hnjtpf7" class="v1"><br /></span><span id="zplv9dr" class="v1"></span><span id="799999j" class="v1"></span><br /><span id="ljvfz99" class="v1"></span><img src ="http://m.tkk7.com/JafeLee/aggbug/118706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/JafeLee/" target="_blank">Jafe</a> 2007-05-20 18:27 <a href="http://m.tkk7.com/JafeLee/archive/2007/05/20/118706.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://m.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://masfd.com" target="_blank">久久久久亚洲av无码专区导航 </a>| <a href="http://jinmenonline.com" target="_blank">www成人免费观看网站</a>| <a href="http://appmofun.com" target="_blank">亚洲欧洲综合在线</a>| <a href="http://jiayila.com" target="_blank">国产亚洲精久久久久久无码77777</a>| <a href="http://lanchenews.com" target="_blank">国产精品免费观看久久</a>| <a href="http://zbsensor.com" target="_blank">日韩免费无码视频一区二区三区</a>| <a href="http://kkjk123.com" target="_blank">一级毛片免费全部播放</a>| <a href="http://96j6.com" target="_blank">亚洲乱码国产乱码精华</a>| <a href="http://fjwkjx.com" target="_blank">亚洲制服丝袜在线播放</a>| <a href="http://97chaopeng2.com" target="_blank">亚洲AV无码一区东京热</a>| <a href="http://ittenyear.com" target="_blank">亚洲中文字幕久久精品无码APP</a>| <a href="http://www99xyxy.com" target="_blank">国产免费131美女视频</a>| <a href="http://cdhxfj.com" target="_blank">最近的中文字幕大全免费版</a>| <a href="http://6t23.com" target="_blank">99re视频精品全部免费</a>| <a href="http://hylaowu.com" target="_blank">免费观看久久精彩视频</a>| <a href="http://shelaoban.com" target="_blank">91av免费在线视频</a>| <a href="http://mlhcd.com" target="_blank">四虎一区二区成人免费影院网址 </a>| <a href="http://kssijia.com" target="_blank">午夜一级免费视频</a>| <a href="http://www-13696.com" target="_blank">桃子视频在线观看高清免费完整</a>| <a href="http://cc45987.com" target="_blank">免费日本一区二区</a>| <a href="http://3atv66.com" target="_blank">久久精品国产免费</a>| <a href="http://amjt9.com" target="_blank">日本一区午夜艳熟免费</a>| <a href="http://tv787.com" target="_blank">国产在线播放线91免费</a>| <a href="http://0515bh.com" target="_blank">一区二区三区免费高清视频</a>| <a href="http://pgyadv.com" target="_blank">猫咪免费人成网站在线观看入口 </a>| <a href="http://liulaogendawutai.com" target="_blank">国产免费观看网站</a>| <a href="http://jiajuco.com" target="_blank">国产精品二区三区免费播放心</a>| <a href="http://a8g8.com" target="_blank">www.999精品视频观看免费</a>| <a href="http://54vpn.com" target="_blank">2021久久精品免费观看</a>| <a href="http://517fanfan.com" target="_blank">亚洲一级毛片免费在线观看</a>| <a href="http://fense1.com" target="_blank">久久综合给合久久国产免费</a>| <a href="http://ywgj50225.com" target="_blank">久久国产乱子免费精品</a>| <a href="http://micehunan.com" target="_blank">青青草原1769久久免费播放</a>| <a href="http://jiezinet.com" target="_blank">亚欧免费无码aⅴ在线观看</a>| <a href="http://fsweicheng.com" target="_blank">亚洲成人免费在线</a>| <a href="http://xmjcjc.com" target="_blank">中文字幕无码播放免费</a>| <a href="http://2xpp.com" target="_blank">国产免费毛不卡片</a>| <a href="http://g8zb.com" target="_blank">免费的一级黄色片</a>| <a href="http://goodwaysi.com" target="_blank">免费大学生国产在线观看p</a>| <a href="http://91ttvv.com" target="_blank">www亚洲一级视频com</a>| <a href="http://miya863.com" target="_blank">中文字幕亚洲日韩无线码</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>