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

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>
            中文高清一区| 亚洲美女在线观看| 久久成人18免费观看| 午夜精品久久久久| 红桃视频欧美| 亚洲人体一区| 国产精品夫妻自拍| 久久国产精品亚洲77777| 久久麻豆一区二区| 日韩亚洲欧美综合| 亚洲一区二区免费| 1000部精品久久久久久久久| 亚洲高清网站| 国产精品日韩精品欧美在线| 久久亚洲精品视频| 欧美精品一区二区三区视频| 亚洲免费网址| 久久视频在线视频| 亚洲私人影院在线观看| 欧美在线观看一区二区| 亚洲国产乱码最新视频| 99视频精品全部免费在线| 国产欧美婷婷中文| 亚洲人体一区| 国产在线精品二区| 日韩视频免费在线观看| 海角社区69精品视频| 亚洲三级观看| 亚洲成人中文| 亚洲综合欧美| 一区二区三区日韩欧美| 久久精品理论片| 亚洲一区成人| 欧美国产欧美综合| 久久女同互慰一区二区三区| 欧美小视频在线| 欧美大片在线影院| 国精品一区二区| 亚洲在线第一页| 一区二区91| 欧美α欧美αv大片| 久久久www成人免费精品| 欧美日韩一区二区在线| 亚洲电影第三页| 韩国一区电影| 欧美一区二区三区男人的天堂| 亚洲视频高清| 欧美日韩国产在线播放网站| 免费日韩成人| 在线欧美小视频| 欧美一区二区三区免费观看| 午夜一区二区三视频在线观看| 欧美激情网友自拍| 亚洲高清一区二| 在线观看一区视频| 久久亚洲春色中文字幕久久久| 久久久人成影片一区二区三区观看| 欧美性猛片xxxx免费看久爱| 亚洲精品女人| 亚洲国产精品悠悠久久琪琪| 久久久久.com| 欧美高清在线精品一区| 亚洲第一福利视频| 免费视频最近日韩| 欧美激情一区二区三区在线视频| 尹人成人综合网| 久热国产精品| 亚洲激情亚洲| 亚洲视频在线观看| 国产精品久久久久久久电影| 一区二区欧美在线| 香港久久久电影| 国产视频一区免费看| 欧美在线高清| 免费精品99久久国产综合精品| 亚洲电影免费在线观看| 你懂的国产精品永久在线| 亚洲国产高潮在线观看| 一区二区三区鲁丝不卡| 国产精品超碰97尤物18| 性刺激综合网| 欧美成人自拍| 亚洲午夜视频在线| 国产伦精品一区二区三区照片91| 欧美在线免费视屏| 欧美激情一区二区三区| 中文精品一区二区三区 | 欧美xart系列在线观看| 亚洲国产精品久久精品怡红院| 欧美精品久久久久久久久老牛影院| 日韩网站免费观看| 久久精品二区三区| 最新成人在线| 国产日韩欧美a| 免费永久网站黄欧美| 日韩一区二区久久| 裸体素人女欧美日韩| 亚洲最新在线| 黑人巨大精品欧美黑白配亚洲| 欧美成人免费大片| 亚洲欧美日韩国产成人| 欧美激情中文不卡| 性欧美大战久久久久久久免费观看| 在线成人欧美| 国产精品久久久久久久app | 亚洲国产精品传媒在线观看| 亚洲永久在线观看| 亚洲国产第一页| 国产精品久久一区主播| 老司机久久99久久精品播放免费| 亚洲午夜高清视频| 亚洲国产合集| 久久一日本道色综合久久| 亚洲午夜av| 亚洲欧洲在线一区| 黑人巨大精品欧美一区二区小视频| 欧美日韩高清不卡| 欧美va亚洲va国产综合| 欧美一区二区高清在线观看| 亚洲精品中文字幕有码专区| 猛男gaygay欧美视频| 香蕉精品999视频一区二区| 亚洲免费av电影| 在线观看中文字幕亚洲| 国产一区av在线| 国产乱码精品一区二区三区五月婷| 欧美日韩1区2区| 欧美激情小视频| 免费影视亚洲| 麻豆九一精品爱看视频在线观看免费| 亚洲欧美制服中文字幕| 亚洲视频一区二区| 99在线精品视频| 9色精品在线| av成人免费观看| av成人黄色| 一区二区三区视频在线| 99精品视频免费观看视频| 最新国产成人av网站网址麻豆| 欧美顶级大胆免费视频| 欧美国产在线电影| 亚洲国产你懂的| 亚洲美女av电影| 99国产精品| 亚洲在线视频免费观看| 亚洲男女自偷自拍图片另类| 亚洲尤物视频在线| 欧美亚洲一区在线| 久久都是精品| 久久蜜桃精品| 欧美成人免费小视频| 欧美精品久久久久久| 欧美三级午夜理伦三级中文幕| 欧美日韩一二三四五区| 国产精品久久久久7777婷婷| 国产欧美日韩在线视频| 国内精品久久久久伊人av| 精品1区2区3区4区| 亚洲日本成人| 亚洲一区欧美激情| 久久精品123| 欧美成人综合| 一个色综合av| 久久久久久九九九九| 欧美aaaaaaaa牛牛影院| 欧美视频一区二区三区四区| 国产精品自在线| 亚洲国产一区视频| 亚洲午夜精品网| 久久伊人精品天天| 亚洲每日更新| 欧美一区二区三区在线免费观看| 榴莲视频成人在线观看| 欧美午夜激情在线| 韩国av一区二区三区四区| 一道本一区二区| 麻豆国产va免费精品高清在线| 亚洲三级免费| 久久成人免费日本黄色| 欧美另类视频在线| 国内精品视频666| 亚洲午夜羞羞片| 免费观看日韩| 亚洲免费影视第一页| 欧美夫妇交换俱乐部在线观看| 国产伦精品一区二区三区免费迷| 亚洲二区在线| 久久久www成人免费无遮挡大片| 亚洲国产精品99久久久久久久久| 亚洲免费视频一区二区| 欧美激情bt| 又紧又大又爽精品一区二区| 亚洲午夜在线| 亚洲欧洲另类国产综合| 欧美自拍丝袜亚洲| 国产精品视频你懂的| 亚洲精品一区二区在线观看| 久久频这里精品99香蕉| 亚洲免费在线电影| 欧美性天天影院|