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

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 閱讀(345) 評論(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>
            亚洲欧美在线另类| 久久综合影视| 国产欧美一区二区三区国产幕精品 | 久久视频精品在线| 亚洲深夜福利| 在线视频免费在线观看一区二区| 欧美日韩在线视频首页| 午夜精品久久久久影视 | 欧美成人午夜剧场免费观看| 久久综合久久综合九色| 亚洲精品社区| 亚洲伊人观看| 在线观看免费视频综合| 亚洲精品影视| 国产午夜精品久久久久久免费视 | 亚洲精品综合久久中文字幕| 亚洲国产日韩欧美在线99| 欧美国产精品人人做人人爱| 亚洲人体大胆视频| 99精品黄色片免费大全| 国产伦精品一区二区三区视频孕妇| 久久精品免费电影| 欧美激情一区二区三区四区| 午夜精品久久久久| 美女91精品| 久久国产精品亚洲va麻豆| 久久婷婷综合激情| 亚洲一区日本| 免费国产自线拍一欧美视频| 午夜亚洲伦理| 欧美不卡视频一区| 久久精品亚洲一区二区三区浴池| 欧美激情视频一区二区三区不卡| 香蕉国产精品偷在线观看不卡| 久久婷婷国产综合尤物精品| 亚洲女同同性videoxma| 久久一区二区视频| 欧美在线综合| 欧美日韩亚洲一区三区| 欧美成人国产va精品日本一级| 国产精品久久久久久久久| 欧美国产日本在线| 国内精品国语自产拍在线观看| 亚洲精品乱码久久久久久按摩观| 国产一区清纯| 亚洲午夜久久久| 在线视频你懂得一区二区三区| 久久久之久亚州精品露出| 午夜精品美女自拍福到在线| 欧美电影免费网站| 你懂的视频一区二区| 国产日韩欧美自拍| 亚洲无亚洲人成网站77777 | 国产精品男gay被猛男狂揉视频| 欧美电影资源| 伊人久久亚洲影院| 久久精品99无色码中文字幕| 久久激情五月婷婷| 国产精品一级| 香蕉久久一区二区不卡无毒影院 | 亚洲美女av黄| 免费视频一区二区三区在线观看| 久久久91精品国产| 国产日韩欧美一区二区三区在线观看| 亚洲欧洲一区二区三区在线观看 | 精品不卡在线| 久久精品论坛| 欧美大片国产精品| 亚洲国产小视频| 欧美成人免费视频| 亚洲区在线播放| 一本色道久久综合一区| 欧美精品激情blacked18| 亚洲人成毛片在线播放| 99精品视频免费观看| 欧美另类女人| 日韩视频在线你懂得| 一区二区三区av| 国产精品久久久久久av下载红粉 | 欧美暴力喷水在线| 亚洲国产毛片完整版| 欧美激情精品久久久久久蜜臀| 亚洲黄色免费电影| 一区二区国产精品| 国产精品视频免费一区| 亚洲欧美第一页| 久久久欧美精品| 亚洲国产婷婷香蕉久久久久久99 | 蜜臀va亚洲va欧美va天堂| 亚洲人成小说网站色在线| 99热在线精品观看| 国产精品99一区二区| 午夜一区二区三区不卡视频| 久久久久久久久蜜桃| 亚洲国产一区二区三区高清| 欧美三区在线观看| 久久精品亚洲| 亚洲美洲欧洲综合国产一区| 欧美伊久线香蕉线新在线| 精品va天堂亚洲国产| 欧美日韩精品在线观看| 亚洲视频一二三| 你懂的亚洲视频| 亚洲欧美另类久久久精品2019| 国产午夜精品久久久久久久| 欧美高清在线一区| 亚洲欧美清纯在线制服| 欧美国产日本在线| 欧美一区午夜精品| 日韩一区二区免费高清| 国产一区二区丝袜高跟鞋图片| 欧美激情综合五月色丁香| 性娇小13――14欧美| 亚洲乱码一区二区| 欧美黄在线观看| 久久精品动漫| 亚洲午夜视频在线观看| 亚洲第一级黄色片| 国产视频一区在线观看| 欧美日韩在线观看一区二区三区| 欧美在线视频免费观看| 日韩视频在线永久播放| 欧美好骚综合网| 久久亚洲国产精品一区二区| 亚洲一二三四区| 一本久久综合亚洲鲁鲁| 亚洲高清在线精品| 狠狠色综合色区| 国产欧美精品va在线观看| 国产精品成人aaaaa网站 | 中文一区字幕| 亚洲精品视频中文字幕| 亚洲第一综合天堂另类专| 麻豆九一精品爱看视频在线观看免费| 亚洲永久视频| 亚洲欧美成人| 亚洲影音一区| 亚洲欧美激情一区| 亚洲欧美怡红院| 亚洲免费影视第一页| 亚洲午夜激情网站| 亚洲视频在线播放| 亚洲私人影院| 亚洲午夜激情| 午夜伦理片一区| 欧美在线播放一区二区| 欧美一区二区三区成人| 久久激情综合网| 久久午夜电影| 欧美成人高清| 91久久在线视频| 99精品国产一区二区青青牛奶| 99综合视频| 亚洲女人天堂成人av在线| 亚洲欧美怡红院| 久久精品99| 欧美电影美腿模特1979在线看| 欧美韩日精品| 国产精品乱码久久久久久| 国产乱码精品一区二区三区忘忧草| 国产九九视频一区二区三区| 国产视频一区二区在线观看| 国产在线欧美日韩| 亚洲国产高清高潮精品美女| 亚洲三级免费观看| 亚洲一区免费视频| 久久久夜夜夜| 亚洲激情网站| 午夜亚洲视频| 欧美成人免费观看| 国产精品国产自产拍高清av王其 | 亚洲第一福利社区| 一区二区激情视频| 久久久视频精品| 亚洲精品黄网在线观看| 香蕉久久精品日日躁夜夜躁| 欧美aⅴ99久久黑人专区| 欧美亚洲第一页| 1000部国产精品成人观看| 夜夜夜久久久| 久久中文字幕一区| 亚洲免费观看高清完整版在线观看熊 | 中文无字幕一区二区三区| 欧美在线免费播放| 亚洲国产精品久久久久久女王| 这里只有精品视频在线| 久久久久久夜精品精品免费| 欧美三区美女| 亚洲日本免费| 久久色中文字幕| 亚洲小说春色综合另类电影| 快she精品国产999| 国产亚洲精品aa午夜观看| 一本色道**综合亚洲精品蜜桃冫| 欧美一区二区三区婷婷月色| 亚洲日韩视频| 美女露胸一区二区三区| 国产视频精品xxxx| 亚洲免费影院| 亚洲精品影视在线观看|