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

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>
            亚洲高清不卡在线观看| 欧美一区二区视频网站| 欧美国产日本高清在线| 免费观看日韩av| 亚洲久久成人| 99视频精品| 国产精品美女www爽爽爽视频| 欧美一区二区三区在线观看视频 | 一区二区三区四区五区精品视频 | 亚洲线精品一区二区三区八戒| 欧美日韩国产精品自在自线| 亚洲欧美影院| 久久精品国内一区二区三区| 亚洲韩国日本中文字幕| a4yy欧美一区二区三区| 国产欧美一区二区三区久久人妖 | 亚洲午夜精品视频| 亚洲综合视频一区| 在线观看成人av| 亚洲三级电影在线观看| 国产精品久久久久影院亚瑟| 久久夜色精品国产| 欧美日韩情趣电影| 欧美一级淫片播放口| 久久在线91| 午夜精品美女久久久久av福利| 午夜精品美女久久久久av福利| 亚洲激情亚洲| 午夜精品美女自拍福到在线| 日韩小视频在线观看| 亚洲欧美另类在线观看| 99re这里只有精品6| 欧美亚洲免费| 中日韩美女免费视频网址在线观看| 亚洲欧美激情四射在线日| 日韩午夜三级在线| 久久国产精品免费一区| 在线视频你懂得一区| 欧美在线亚洲综合一区| 亚洲一二三区视频在线观看| 欧美一级一区| 亚洲欧美一区二区三区久久| 欧美精品v日韩精品v韩国精品v| 久久爱www.| 欧美三级网址| 亚洲欧洲视频| 亚洲欧洲一区二区三区在线观看 | 91久久亚洲| 在线日韩欧美视频| 欧美一区二区在线免费观看| 日韩特黄影片| 蜜臀av性久久久久蜜臀aⅴ四虎 | 欧美在线视频在线播放完整版免费观看 | 久久久精品动漫| 国产精品亚洲综合| 一区二区三区av| 日韩亚洲欧美一区二区三区| 欧美 日韩 国产一区二区在线视频| 久久久夜色精品亚洲| 亚洲天堂成人在线视频| 欧美精品首页| 最新成人在线| 一区二区三区视频免费在线观看| 女同一区二区| 亚洲黄色尤物视频| 日韩亚洲欧美中文三级| 欧美va天堂在线| 亚洲国产欧美一区二区三区丁香婷| 一区视频在线| 女人天堂亚洲aⅴ在线观看| 亚洲第一黄色| 亚洲人久久久| 欧美精品在线观看一区二区| 亚洲精品国精品久久99热| 一区二区三区蜜桃网| 国产精品va在线播放| 亚洲小说欧美另类社区| 久久国产毛片| 最新日韩中文字幕| 欧美日韩91| 亚洲一区欧美二区| 久久亚洲春色中文字幕久久久| 国产综合久久| 另类av一区二区| 一本色道久久88综合日韩精品 | 经典三级久久| 欧美经典一区二区| 亚洲视频自拍偷拍| 久久乐国产精品| 亚洲精品无人区| 国产精品蜜臀在线观看| 久久久99国产精品免费| 亚洲欧洲精品一区二区精品久久久| 中文精品视频| 国内自拍一区| 欧美日韩国产黄| 午夜精品区一区二区三| 亚洲国产天堂久久综合| 亚洲欧美日韩视频一区| 黄色一区二区在线观看| 欧美女激情福利| 久久黄色影院| 日韩亚洲欧美中文三级| 久久午夜精品一区二区| 一区二区高清视频在线观看| 国产综合自拍| 欧美色区777第一页| 久久视频这里只有精品| 亚洲一区二区三区在线播放| 欧美肥婆bbw| 香蕉免费一区二区三区在线观看 | 亚洲激情电影在线| 国产欧美日韩一级| 欧美日韩亚洲另类| 久久久久综合网| 亚洲一区免费看| 最新日韩精品| 欧美.www| 久久蜜桃资源一区二区老牛| 亚洲网站啪啪| 亚洲精品一区二区三区蜜桃久| 国产一区二区福利| 国产精品欧美日韩一区二区| 欧美精品久久久久久久久老牛影院| 久久久亚洲国产天美传媒修理工| 亚洲视频综合| 欧美日韩国产专区| 久久精品盗摄| 亚洲在线视频一区| 一本久久知道综合久久| 亚洲日本免费| 亚洲国产毛片完整版| 欧美第十八页| 欧美成人一区二区三区在线观看 | 中文日韩在线| 亚洲精品综合在线| 欧美激情视频一区二区三区在线播放| 久久gogo国模啪啪人体图| 午夜久久99| 亚洲已满18点击进入久久| 亚洲视频观看| 亚洲综合色丁香婷婷六月图片| 亚洲另类视频| 日韩视频中文| 中日韩美女免费视频网址在线观看| 99国产麻豆精品| 中文高清一区| 午夜欧美不卡精品aaaaa| 午夜精品三级视频福利| 香蕉久久久久久久av网站| 亚洲专区国产精品| 欧美一区二区三区日韩视频| 久久精品二区亚洲w码| 久久久精品日韩欧美| 久久av在线看| 欧美freesex8一10精品| 欧美久色视频| 国产免费观看久久黄| 国产婷婷色一区二区三区在线| 黑人巨大精品欧美一区二区| 影音先锋久久久| 亚洲裸体视频| 亚洲欧美日韩国产中文| 久久先锋影音av| 亚洲日本视频| 亚洲影院高清在线| 久久久久一本一区二区青青蜜月| 欧美1区2区3区| 国产精品高精视频免费| 国产欧美一区二区三区国产幕精品| 伊人精品在线| 中国女人久久久| 久久一区二区三区av| 亚洲欧洲三级电影| 亚洲欧洲99久久| 欧美二区视频| 国产精品综合| 亚洲伦理一区| 久久久久免费| 999在线观看精品免费不卡网站| 亚洲欧美成人一区二区三区| 美女脱光内衣内裤视频久久影院| 欧美日韩视频在线观看一区二区三区| 国产欧美短视频| 日韩午夜剧场| 美女视频网站黄色亚洲| 亚洲深夜福利在线| 久久夜色精品一区| 国产精品一区二区三区乱码| 91久久精品久久国产性色也91| 午夜视频久久久| 亚洲国产日韩一区| 欧美亚洲综合网| 欧美日韩精品三区| 亚洲国产成人久久| 久久国产乱子精品免费女| 亚洲免费播放| 欧美大片一区| 亚洲高清资源| 久久资源av|