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

M-A-T Tory's Blog

  C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  16 隨筆 :: 1 文章 :: 1 評(píng)論 :: 0 Trackbacks
1. 隨機(jī)數(shù)
? // 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");

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

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

//相同常量的引用,相等
System.out.println(?name3?==?name4?);
//內(nèi)容,相等
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 閱讀(340) 評(píng)論(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>
            香蕉免费一区二区三区在线观看 | 国产深夜精品| 亚洲男同1069视频| 亚洲性夜色噜噜噜7777| 国产精品伦子伦免费视频| 午夜精品国产精品大乳美女| 中文有码久久| 国产一级久久| 欧美aaaaaaaa牛牛影院| 欧美成人午夜影院| 在线视频你懂得一区| 亚洲性线免费观看视频成熟| 国产欧美一区二区精品婷婷| 久久久久久久999精品视频| 久久男人av资源网站| 91久久综合亚洲鲁鲁五月天| 亚洲美女中出| 国产手机视频精品| 欧美国产亚洲视频| 欧美性淫爽ww久久久久无| 久久久久久夜| 欧美精品18+| 欧美一区二区三区另类| 久久这里有精品视频| 日韩亚洲精品在线| 先锋影音国产一区| 亚洲美女视频网| 亚洲女同在线| 日韩视频在线观看国产| 欧美中文在线视频| 一二美女精品欧洲| 久久久久88色偷偷免费| 国产精品99久久久久久久女警 | 亚洲视频导航| 亚洲丶国产丶欧美一区二区三区| 亚洲精品裸体| 国产在线成人| 一区二区三区|亚洲午夜| 亚洲高清久久久| 亚洲欧美日韩国产中文| 亚洲片在线资源| 久久都是精品| 亚洲欧美精品伊人久久| 欧美成人国产| 久久美女艺术照精彩视频福利播放| 欧美日韩国产色视频| 久久永久免费| 国产在线精品一区二区夜色| 亚洲美女黄色片| 91久久久精品| 久久欧美中文字幕| 久久久人成影片一区二区三区观看 | 久久精品在线观看| 国产精品久久久久毛片软件| 欧美激情视频在线免费观看 欧美视频免费一| 国产精品日韩欧美一区| 99国产精品国产精品久久 | 国产精品色网| 日韩午夜在线| 国产精品99久久不卡二区| 欧美精品一线| 亚洲国产精品久久久久秋霞蜜臀 | 欧美黑人在线播放| 亚洲国产精品一区制服丝袜 | 国产真实乱子伦精品视频| 亚洲网站啪啪| 午夜精品影院| 国产日产亚洲精品| 亚洲欧美日韩精品综合在线观看| 亚洲深夜福利在线| 蜜臀av一级做a爰片久久 | 国产精品欧美久久| 91久久黄色| 极品尤物久久久av免费看| 一区二区三区免费在线观看| 日韩视频免费观看高清完整版| 欧美在线你懂的| 欧美一区二区视频在线| 国产精品久久久久免费a∨大胸| 亚洲国产精品久久久久| 玉米视频成人免费看| 欧美aⅴ99久久黑人专区| 巨乳诱惑日韩免费av| 黑人极品videos精品欧美裸| 午夜免费在线观看精品视频| 欧美一区二区三区免费视| 国产精品久久久久毛片大屁完整版| 99精品欧美一区| 一区二区三区导航| 国产视频久久网| 久久av一区二区三区| 久久久亚洲精品一区二区三区| 国产日韩亚洲| 久久精品中文字幕一区| 欧美国产日韩一区二区三区| 亚洲第一视频| 欧美xx视频| 亚洲欧美999| 看片网站欧美日韩| 亚洲电影观看| 欧美另类人妖| 亚洲午夜激情在线| 久久九九久精品国产免费直播| 国产一区二区三区在线观看精品| 亚洲欧美另类国产| 亚洲福利在线观看| 亚洲图片在区色| 国产日韩1区| 免费黄网站欧美| 亚洲另类黄色| 久久岛国电影| 亚洲精品乱码视频| 国产精品老女人精品视频| 久久九九精品| 亚洲茄子视频| 久久精品1区| 亚洲欧洲精品一区二区三区不卡| 欧美日韩在线综合| 久久av一区二区三区漫画| 一区二区三区四区五区在线| 久久久一二三| 99视频精品| 黄色亚洲在线| 欧美午夜不卡影院在线观看完整版免费 | 欧美—级a级欧美特级ar全黄| 99视频超级精品| 久久午夜av| 亚洲一区二区三区中文字幕 | 久久在线免费观看| aa级大片欧美三级| 免费不卡在线视频| 性高湖久久久久久久久| 亚洲精品日日夜夜| 国产在线视频欧美| 欧美日韩亚洲国产一区| 久久久久国产精品厨房| 一本到高清视频免费精品| 欧美xxxx在线观看| 欧美在线黄色| 亚洲在线中文字幕| 亚洲精品国产拍免费91在线| 最新中文字幕亚洲| 影音先锋亚洲精品| 国产欧美日韩综合| 国产精品久久久久久久久免费樱桃| 久久综合色天天久久综合图片| 亚洲无限av看| 欧美成人免费在线| 噜噜噜91成人网| 久久日韩精品| 久久九九热免费视频| 亚洲女ⅴideoshd黑人| 夜夜嗨网站十八久久| 亚洲伦理网站| 影音先锋久久资源网| 亚洲国产天堂网精品网站| 国内精品免费在线观看| 国产一区二区三区观看| 国产伦精品一区二区三区四区免费| 欧美日韩高清在线| 欧美国产精品日韩| 玖玖综合伊人| 欧美精品v国产精品v日韩精品| 女女同性精品视频| 欧美国产激情| 欧美日韩伊人| 国产精品第13页| 国产精品高潮久久| 欧美激情中文字幕在线| 欧美四级在线| 国产老女人精品毛片久久| 欧美午夜电影网| 国产精品美女午夜av| 国产精品视频免费在线观看| 国产精品久久久久久久久免费桃花 | 亚洲日产国产精品| 一级日韩一区在线观看| 亚洲午夜精品| 久久超碰97人人做人人爱| 久久久久综合网| 蜜桃久久精品乱码一区二区| 美女日韩欧美| 亚洲激情偷拍| 国产精品99久久久久久久久| 亚洲无人区一区| 你懂的成人av| 欧美三区免费完整视频在线观看| 国产精品成人免费视频| 欧美日韩八区| 亚洲大胆美女视频| 99爱精品视频| 欧美在线视频一区| 欧美成人国产一区二区| 亚洲精品一区在线观看| 一本色道久久综合狠狠躁篇的优点 | 激情五月综合色婷婷一区二区| 亚洲国产高清在线观看视频| 一区二区三区国产精品| 久久久精品动漫| 亚洲高清在线播放|