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

M-A-T Tory's Blog

  C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
  16 隨筆 :: 1 文章 :: 1 評論 :: 0 Trackbacks
1. 隨機數(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");

//兩個對象的引用,不相等
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 閱讀(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>
            欧美激情一区二区三区在线| 欧美激情1区2区| 欧美成人一区二区三区在线观看| 国模套图日韩精品一区二区| 久久久人成影片一区二区三区观看 | 香蕉久久a毛片| 亚洲欧美日韩在线播放| 国产欧美日韩一区二区三区在线观看 | 欧美综合第一页| 欧美在线播放| 亚洲黄色成人网| 亚洲国产中文字幕在线观看| 久久国产欧美| 亚洲国产一区二区a毛片| 亚洲国产天堂久久综合| 欧美日韩美女在线| 亚洲欧美中日韩| 久久久另类综合| 欧美一级久久久久久久大片| 久久久亚洲午夜电影| 在线一区二区日韩| 欧美在线视频观看免费网站| 亚洲美女黄网| 亚洲理论电影网| 亚洲国内在线| 午夜老司机精品| 亚洲人成在线观看一区二区| 牛牛精品成人免费视频| 欧美日韩亚洲高清| 久久精品日韩| 欧美特黄一级| 亚洲日本中文| 亚洲日本va午夜在线电影| 欧美在线影院| 欧美在线视频在线播放完整版免费观看| 欧美久久久久久久久| 亚洲第一色在线| 狠狠爱综合网| 亚洲欧美另类中文字幕| 制服丝袜激情欧洲亚洲| 欧美成va人片在线观看| 久久精品欧美| 国产一区二区日韩精品欧美精品| 亚洲黄网站在线观看| 国产午夜精品全部视频在线播放| 91久久精品国产91久久| 国产在线视频欧美| 亚洲午夜精品17c| 夜夜嗨av一区二区三区四区| 久久视频在线看| 久久精品盗摄| 欧美自拍偷拍午夜视频| 欧美肉体xxxx裸体137大胆| 嫩模写真一区二区三区三州| 国产精品一区二区在线观看不卡| 亚洲国产高清aⅴ视频| 怡红院精品视频| 午夜精品短视频| 午夜精品久久久久| 欧美精品在线免费| 亚洲国产日韩一区二区| 亚洲盗摄视频| 99热这里只有成人精品国产| 亚洲日本乱码在线观看| 久久综合国产精品| 老司机一区二区| 国产综合久久久久久鬼色| 亚洲欧美卡通另类91av | 亚洲成色www久久网站| 亚洲免费婷婷| 亚洲欧美日韩国产一区| 欧美午夜电影完整版| 99精品国产福利在线观看免费| 亚洲精选大片| 欧美1区2区3区| 久久久久国产精品厨房| 欧美婷婷六月丁香综合色| 亚洲乱码国产乱码精品精可以看| 亚洲精品久久久久中文字幕欢迎你 | 久久国产欧美| 国产嫩草影院久久久久 | 国产精品高潮呻吟| 亚洲尤物影院| 久久久久久穴| 国产在线精品一区二区夜色| 久久久久久91香蕉国产| 女人香蕉久久**毛片精品| 亚洲电影天堂av| 蜜桃av一区二区| 亚洲精品免费一二三区| 一区二区欧美激情| 国产精品久久久久久久久久妞妞| 亚洲综合清纯丝袜自拍| 欧美一区二区免费视频| 国产日韩欧美不卡| 久久精品视频在线| 亚洲国产成人porn| 亚洲欧美精品| 国产精品爱久久久久久久| 羞羞答答国产精品www一本| 你懂的视频欧美| 一二三区精品福利视频| 国产精品女同互慰在线看| 久久福利毛片| 久久久无码精品亚洲日韩按摩| 国产日韩亚洲欧美精品| 一区二区三区久久久| 久久影音先锋| 在线综合亚洲欧美在线视频| 亚洲日韩中文字幕在线播放| 久久精品国产91精品亚洲| 国产精品乱子乱xxxx| 久久久最新网址| 亚洲精品日韩欧美| 久久精品国产免费| 亚洲精选大片| 国产午夜精品视频| 免费中文字幕日韩欧美| 这里只有精品在线播放| 久热成人在线视频| 夜夜狂射影院欧美极品| 国产欧美日韩在线视频| 欧美精品一区二区三区在线播放 | 国内精品嫩模av私拍在线观看| 免费一区视频| 亚洲砖区区免费| 亚洲精品乱码久久久久久久久 | 狠狠综合久久| 欧美性片在线观看| 欧美3dxxxxhd| 久久成人人人人精品欧| 中文精品视频| 亚洲经典自拍| 欧美freesex交免费视频| 一本色道久久综合亚洲91| 国产精品国产福利国产秒拍| 午夜精品亚洲| 亚洲缚视频在线观看| 久久久综合精品| 校园激情久久| 日韩视频免费看| 亚洲人成亚洲人成在线观看| 国产日韩精品久久久| 欧美日本中文字幕| 欧美aⅴ99久久黑人专区| 欧美午夜在线| 久久五月婷婷丁香社区| 亚洲欧美文学| 亚洲香蕉成视频在线观看 | 欧美国产日韩xxxxx| 欧美在线影院在线视频| 亚洲一区一卡| 一本色道久久综合精品竹菊| 亚洲片区在线| 国产精品有限公司| 国产精品久久久爽爽爽麻豆色哟哟| 欧美日韩蜜桃| 欧美日韩网址| 欧美日韩亚洲成人| 欧美日韩国产影院| 欧美激情免费在线| 欧美精品尤物在线| 欧美精品成人91久久久久久久| 久久九九电影| 久久久国产视频91| 久久综合久久久久88| 久久午夜激情| 免播放器亚洲| 久久gogo国模裸体人体| 欧美亚洲免费电影| 欧美专区日韩专区| 久久手机精品视频| 久久综合国产精品| 欧美精品一区二区三区视频| 欧美伦理a级免费电影| 欧美人与性动交α欧美精品济南到| 欧美激情一区在线观看| 欧美三日本三级少妇三99| 欧美视频网址| 国产精品一二三四区| 国产主播精品| 在线观看成人一级片| 亚洲人成网在线播放| 亚洲黄色在线视频| 99在线|亚洲一区二区| 亚洲国产99精品国自产| 麻豆91精品| 欧美福利专区| 亚洲美洲欧洲综合国产一区| 在线亚洲自拍| 欧美专区福利在线| 欧美成人一区二区| 欧美精品一区二区三区在线看午夜| 免费亚洲电影| 欧美体内谢she精2性欧美| 国产欧美一区二区视频| 在线看不卡av| 亚洲福利在线观看| 久久国产精品99久久久久久老狼| 久久三级福利|