青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

M-A-T Tory's Blog

  C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
  16 隨筆 :: 1 文章 :: 1 評論 :: 0 Trackbacks
1. 隨機數
? // Create a random number generator,
?? // seeds with current time by default:

Random?rand?=?new?Random();

????
int?i,?j,?k;
???
//?Choose?value?from?1?to?100:
????j?=?rand.nextInt(100)?+?1;
2. Aliasing during method calls
class?Letter?{
??char?c;
}

public?
class?PassObject?{
????static?void?f(Letter?y)?{
????y.c?
=?'z';
??}
??public?static?void?main(String[]?args)?{
????Letter?x?
=?new?Letter();
????x.c?
=?'a';
????System.out.println(
"1:?x.c:?"?+?x.c);
????f(x);
//result:"1:?x.c:?a",
//??????"2:?x.c:?z"
}
}

Passing objects to methods may not be what you're used to. It just pass a reference
3.Also reference
????????Integer?n1?=?new?Integer(47);
??????Integer?n2?
=?new?Integer(47);
????????System.out.println(n1?
==?n2);
????????
//result??false
If you want to compare the actual contents of an object for equivalence. You must use the special method equals(?) that exists for all objects .REMEMBER the default behavior of equals(?) is to compare references.So the result of the fellowing code is false
class?Value?{
??int?i;
}

public?
class?EqualsMethod2?{
???public?static?void?main(String[]?args)?{
????Value?v1?
=?new?Value();
????Value?v2?
=?new?Value();
????v1.i?
=?v2.i?=?100;
????System.out.println(v1.equals(v2));
??
??}
}?
///:~

4.Here’s an example that demonstrates the use of all the operators involving bits:
static?void?printBinaryInt(String?s,?int?i)?{
????System.out.println(
??????s?
+?",?int:?"?+?i?+?",?binary:?");
????System.out.print(
"???");
????
for(int?j?=?31;?j?>=?0;?j--)
??????
if(((1?<<?j)?&??i)?!=?0)
????????System.out.print(
"1");
??????
else
????????System.out.print(
"0");
????System.out.println();
??}

??
static?void?printBinaryLong(String?s,?long?l)?{
????System.out.println(
??????s?
+?",?long:?"?+?l?+?",?binary:?");
????System.out.print(
"???");
????
for(int?i?=?63;?i?>=?0;?i--)
??????
if(((1L?<<?i)?&?l)?!=?0)
????????System.out.print(
"1");
??????
else
????????System.out.print(
"0");
????System.out.println();
??}

Since then goto-bashing has been a popular sport, with advocates? of the cast-out keyword scurrying for cover.

As is typical in situlations like this, the middle ground is the most fruitfull.

5.Here is a demonstration of labeled break and continue statements with whileloops:

import?com.bruceeckel.simpletest.*;

public?class?LabeledWhile?{
??
static?Test?monitor?=?new?Test();
??
public?static?void?main(String[]?args)?{
????
int?i?=?0;
????outer:
????
while(true)?{
??????System.out.println(
"Outer?while?loop");
??????
while(true)?{
????????i
++;
????????System.out.println(
"i?=?"?+?i);
????????
if(i?==?1)?{
??????????System.out.println(
"continue");
??????????
continue;
????????}

????????
if(i?==?3)?{
??????????System.out.println(
"continue?outer");
??????????
continue?outer;
????????}

????????
if(i?==?5)?{
??????????System.out.println(
"break");
??????????
break;
????????}

????????
if(i?==?7)?{
??????????System.out.println(
"break?outer");
??????????
break?outer;
????????}

??????}

????}

????monitor.expect(
new?String[]?{
??????
"Outer?while?loop",
??????
"i?=?1",
??????
"continue",
??????
"i?=?2",
??????
"i?=?3",
??????
"continue?outer",
??????
"Outer?while?loop",
??????
"i?=?4",
??????
"i?=?5",
??????
"break",
??????
"Outer?while?loop",
??????
"i?=?6",
??????
"i?=?7",
??????
"break?outer"
????}
);
??}

}
?///:~

RULES:

  1. A plain continue goes to the top of the innermost loop and continues.
  2. A labeled continue goes to the label and reenters the loop right after that label.
  3. A break “drops out of the bottom” of the loop.
  4. A labeled break drops out of the bottom of the end of the loop denoted by the label.

6. Even differences in the ordering of arguments are sufficient to distinguish two methods.
?
7. Calling constructors from constructors

public?class?Flower?{
??
??
int?petalCount?=?0;
??String?s?
=?new?String("null");
??Flower(
int?petals)?{
????petalCount?
=?petals;
????System.out.println(
??????
"Constructor?w/?int?arg?only,?petalCount=?"
??????
+?petalCount);
??}

??Flower(String?ss)?
{
????System.out.println(
??????
"Constructor?w/?String?arg?only,?s="?+?ss);
????s?
=?ss;
??}

??Flower(String?s,?
int?petals)?{
????
this(petals);
//!????this(s);?//?Can't?call?two!
????this.s?=?s;?//?Another?use?of?"this"
????System.out.println("String?&?int?args");
??}

??Flower()?
{
????
this("hi",?47);
????System.out.println(
"default?constructor?(no?args)");
??}

??
void?print()?{
//!?this(11);?//?Not?inside?non-constructor!
????System.out.println(
??????
"petalCount?=?"?+?petalCount?+?"?s?=?"+?s);
??}

}
9. equal() and "=="
String?name1?=?new?String("Tory");
Stirng?name2?
=?new?String("Tory");

//兩個對象的引用,不相等
System.out.println(?name1?==?name2?);
//內容,相等
System.out.println(?name1.equals(name2));

String?name3?
=?"Tory";
String?name4?
=?"Tory";

//相同常量的引用,相等
System.out.println(?name3?==?name4?);
//內容,相等
System.out.println(?name3.equals(name4));
10.自己的equals()方法
class?MyDate?{

????
int?day,?month,?year;
????
????
public?MyDate?(int?day,?int?month,?int?year){
????
????????
this.day?=?day;
????????
this.month?=?month;
????????
this.year?=?year;
????????
????}
?

}


class?MyOkDate?extends?MyDate?{

????
public?MyOkDate?(?int?day,?int?month,?int?year?)?{
????
????????
super(day,?month,?year);
????????
????????}

????????
????????
public?boolean?equals?(?Object?obj?)?{
????????
????????????
if(?obj?instanceof?MyOkDate?)?{
????????????????MyOkDate?m?
=?(MyOkDate)?obj;
????????????????
if(m.day?==?day?&&?m.month?==?month?&&?m.year?==?year)
????????????????
return?true;
????????????????
????????????}

????????????
return?false;
????????}
?
}


public?class?TestEqualsObject{

????
public?static?void?main?(?String?[]?args?){
????????
????????MyDate?m1?
=?new?MyDate(4,?12,?1985);
????????MyDate?m2?
=?new?MyDate(4,?12,?1985);
????????
????????
//不相等
????????System.out.println(m1.equals(m2));
????????
????????m1?
=?new?MyOkDate(4,?12,?1985);
????????m2?
=?new?MyOkDate(4,?12,?1985);
????????
????????
//相等
????????System.out.println(m1.equals(m2));
?????????
????}

????
}
posted on 2006-04-24 22:36 Tory 閱讀(334) 評論(0)  編輯 收藏 引用 所屬分類: Java Learning
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美日韩在线电影| 亚洲国产va精品久久久不卡综合| 亚洲精品日产精品乱码不卡| 亚洲国产成人av| 欧美一区精品| 久久精品国产77777蜜臀| 久久精品99无色码中文字幕| 久久人人97超碰国产公开结果| 欧美尤物巨大精品爽| 久久久久国产精品麻豆ai换脸| 亚洲一区成人| 国内精品久久久久影院色| 极品中文字幕一区| 亚洲国产另类久久精品| 在线日韩av片| 亚洲一区免费| 久久一区二区三区av| 亚洲电影一级黄| 在线亚洲电影| 老司机免费视频久久| 欧美日韩视频一区二区三区| 国产精品午夜在线观看| 亚洲狠狠丁香婷婷综合久久久| 亚洲一级特黄| 美女999久久久精品视频| 亚洲欧洲一区| 久久国产精品一区二区| 欧美激情2020午夜免费观看| 久久美女性网| 在线观看中文字幕不卡| 激情视频一区二区| 最新国产成人在线观看| 欧美怡红院视频| 欧美国产视频在线| 午夜精品免费| 欧美sm视频| 黄色成人av| 欧美在线网址| 在线综合+亚洲+欧美中文字幕| 蜜桃久久av| 国产一区二区三区av电影| 日韩午夜在线视频| 免费美女久久99| 欧美一区二区三区另类| 欧美性生交xxxxx久久久| 欧美制服丝袜| 亚洲人成在线观看| 久久综合狠狠| 午夜精品美女久久久久av福利| 欧美激情视频一区二区三区免费 | 国产精品一区视频网站| 日韩视频一区二区三区在线播放| 久久aⅴ国产欧美74aaa| 亚洲视频二区| 欧美午夜无遮挡| 亚洲美女区一区| 欧美激情一区二区三区在线视频| 亚欧成人在线| 国产精品亚洲片夜色在线| 亚洲一区精品电影| 亚洲另类自拍| 欧美日韩一区二区三区四区在线观看| 亚洲国产三级网| 亚洲福利视频专区| 欧美www视频| 日韩视频免费在线观看| 欧美国产日韩亚洲一区| 久久久久久久网站| 亚洲国产成人在线播放| 亚洲第一福利在线观看| 欧美成人精品不卡视频在线观看 | 欧美日韩亚洲一区二区三区| 一本不卡影院| 亚洲图片在线观看| 国产三区二区一区久久| 久久久久综合网| 亚洲欧美激情视频在线观看一区二区三区 | 亚洲国产精品va| 欧美电影资源| 欧美激情视频在线免费观看 欧美视频免费一 | 亚洲欧洲精品一区二区精品久久久| 欧美一区二粉嫩精品国产一线天| 国内激情久久| 亚洲人www| 国产欧美精品一区二区三区介绍| 美女爽到呻吟久久久久| 欧美日韩福利视频| 久热爱精品视频线路一| 国产精品一级| 亚洲欧美国产高清| 亚洲免费大片| 欧美日本国产视频| 一区二区精品国产| 性视频1819p久久| 久久久综合香蕉尹人综合网| 久久久久久黄| 欧美日韩午夜剧场| 久久精品国亚洲| 亚洲欧美www| 久久久久成人精品| 1204国产成人精品视频| 亚洲国产成人av好男人在线观看| 国产日韩精品久久| 欧美一区二区在线观看| 久久er99精品| 91久久夜色精品国产九色| 国产亚洲一区精品| 91久久嫩草影院一区二区| 一区二区三区导航| 一本到12不卡视频在线dvd| 久热国产精品视频| 欧美激情精品久久久久久变态| 国产精品视屏| 女主播福利一区| 亚洲午夜久久久| 卡一卡二国产精品| 亚洲尤物在线| 欧美一区=区| 在线视频观看日韩| 亚洲欧美久久久久一区二区三区| 亚洲国产精品久久久久秋霞蜜臀| 亚洲在线观看免费| 一区二区欧美在线观看| 麻豆精品精华液| 久久久国产视频91| 国产精品老牛| 一本久久a久久免费精品不卡| 欧美一级大片在线观看| 亚洲国产欧美日韩| 久久久久久有精品国产| 久久av资源网站| 国产欧美日本一区视频| 中文国产成人精品| 亚洲午夜av在线| 欧美人与性禽动交情品| 亚洲电影专区| 亚洲激情一区二区三区| 久久这里有精品视频| 久久综合影音| 极品裸体白嫩激情啪啪国产精品| 亚洲欧美在线网| 久久本道综合色狠狠五月| 国产精品免费看| 午夜一区二区三区不卡视频| 欧美一区二区在线看| 国产日韩在线一区| 欧美一区二粉嫩精品国产一线天| 久久精品日产第一区二区| 国产日韩欧美三区| 亚洲欧美日韩国产综合在线| 欧美尤物巨大精品爽| 国产一区视频网站| 久久亚洲色图| 最新中文字幕亚洲| 一区二区三区精品久久久| 欧美精彩视频一区二区三区| 日韩亚洲欧美一区| 欧美一级久久| 一区在线影院| 欧美成人午夜| 亚洲午夜在线观看| 久久www免费人成看片高清| 国产一区在线观看视频| 久久夜色精品国产欧美乱极品 | 亚洲精品国产系列| 91久久精品www人人做人人爽| 在线观看精品一区| 欧美日韩三区| 国产一区二区精品久久91| 久久精品国产免费| 欧美激情区在线播放| 亚洲一区二区三区在线视频| 久久综合99re88久久爱| 欧美精品在线网站| 国产丝袜美腿一区二区三区| 夜夜嗨av一区二区三区四区| 99精品欧美一区二区三区| 国产精品久久久久久久久免费| 欧美一区二区三区精品电影| 亚洲激情在线观看| 午夜视频精品| 91久久久久久久久| 国产日韩精品一区二区三区| 欧美成人日韩| 久久久另类综合| 亚洲网址在线| 亚洲国产精品日韩| 免播放器亚洲一区| 欧美亚洲一区二区三区| 国产精品99久久久久久久vr| 在线激情影院一区| 国产欧美日韩视频| 欧美日韩中字| 欧美精品18+| 久久久午夜精品| 午夜久久电影网| av成人免费在线观看| 最近中文字幕mv在线一区二区三区四区 | 欧美激情第三页| 久久精品国产亚洲高清剧情介绍|