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

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>
            亚洲精品永久免费| 亚洲专区免费| 美国成人毛片| 日韩一二在线观看| 欧美一区二区视频观看视频| 韩国v欧美v日本v亚洲v| 久久嫩草精品久久久精品| 亚洲人体影院| 亚洲综合三区| 亚洲第一福利社区| 欧美午夜片欧美片在线观看| 欧美中文字幕不卡| 亚洲午夜视频在线观看| 国产欧美不卡| 欧美成年网站| 午夜视频在线观看一区二区三区| 欧美成黄导航| 新67194成人永久网站| 亚洲经典在线| 国产色视频一区| 欧美精品久久一区二区| 午夜影院日韩| 99re热精品| 欧美不卡一区| 久久国产日韩| 亚洲一区3d动漫同人无遮挡| 亚洲二区在线| 欧美成人国产va精品日本一级| 亚洲另类在线一区| 黄色免费成人| 国产精品揄拍一区二区| 欧美理论在线| 老巨人导航500精品| 亚洲欧美在线一区二区| 日韩午夜在线| 亚洲国产精品久久久久| 久久精品国产综合精品| 亚洲伊人伊色伊影伊综合网| 最新国产成人av网站网址麻豆| 国外视频精品毛片| 国产精品一区二区在线观看网站| 欧美精品乱人伦久久久久久| 久久综合伊人77777尤物| 欧美亚洲综合在线| 亚洲一区二区三区在线| aa成人免费视频| 亚洲日本中文| 亚洲国产精品va在线看黑人 | 久久国产精品99精品国产| 夜夜爽夜夜爽精品视频| 亚洲精品永久免费| 亚洲激情图片小说视频| 亚洲电影毛片| 在线成人激情视频| 在线观看欧美日韩国产| 激情文学一区| 伊人夜夜躁av伊人久久| 狠狠综合久久av一区二区老牛| 国产一区二区丝袜高跟鞋图片| 国产精品手机在线| 国产精品一区二区久久| 国产精品日本| 国产精品制服诱惑| 国产婷婷色一区二区三区在线 | 欧美 日韩 国产一区二区在线视频| 久久九九久精品国产免费直播| 欧美一区二区日韩一区二区| 欧美一区二区免费视频| 欧美中在线观看| 久久国产精品黑丝| 久久久999| 裸体歌舞表演一区二区| 欧美成人在线网站| 亚洲国产精品99久久久久久久久| 亚洲激情欧美| 夜夜精品视频一区二区| 国产精品99久久99久久久二8| 中文在线一区| 欧美一区二区三区喷汁尤物| 久久久精品一区二区三区| 久久婷婷蜜乳一本欲蜜臀| 蜜臀99久久精品久久久久久软件| 欧美大胆人体视频| 欧美日韩一区免费| 国产精品网红福利| 国产亚洲欧洲| 亚洲国产精品va| 欧美日韩在线一区二区三区| 国产精品毛片| 国内精品久久久久久久影视麻豆 | 久久激情五月激情| 麻豆精品网站| 亚洲精品看片| 亚洲男人的天堂在线| 久久精品免费观看| 欧美激情久久久久久| 欧美午夜精品久久久| 国产日韩欧美综合精品| 亚洲国产精品一区二区www| 亚洲社区在线观看| 久久久久国产精品www| 亚洲国产精品久久精品怡红院| 亚洲深夜福利视频| 久久久亚洲影院你懂的| 欧美激情黄色片| 国产欧美三级| 日韩午夜在线| 久久久久久免费| 亚洲精品四区| 久久精品观看| 欧美日韩中文字幕日韩欧美| 国产主播一区二区三区| 日韩午夜剧场| 久久尤物视频| 一区二区欧美在线观看| 久久久久九九九| 国产精品红桃| 亚洲人成网站精品片在线观看 | 久久国产精品72免费观看| 欧美另类视频在线| 激情av一区二区| 亚洲欧美日本日韩| 欧美激情视频在线播放| 午夜视频久久久| 欧美日韩一区二区高清| 在线日韩电影| 久久精品国产亚洲aⅴ| 99riav国产精品| 欧美成人一区二区三区片免费| 国产日韩综合| 亚洲尤物视频网| 亚洲高清在线| 久久青草欧美一区二区三区| 国产精品日韩精品欧美精品| 亚洲精品视频免费观看| 久久亚洲精品一区| 亚洲尤物精选| 欧美视频一区| 亚洲精品在线观看免费| 麻豆精品传媒视频| 先锋影音国产一区| 国产精品入口尤物| 亚洲专区在线视频| 亚洲精品一区二区三区99| 免费久久99精品国产自| 一区在线免费观看| 久久国产精品免费一区| 亚洲一区高清| 国产精品久久久久久五月尺| 99在线精品观看| 亚洲国产精品一区二区www在线| 久久久久免费| 依依成人综合视频| 麻豆freexxxx性91精品| 久久狠狠久久综合桃花| 国产日产欧美一区| 欧美亚洲视频| 亚洲一区二区高清视频| 国产精品国产三级国产专播品爱网 | 宅男噜噜噜66国产日韩在线观看| 欧美激情第4页| 免费成人黄色片| 亚洲经典自拍| 91久久精品网| 欧美日韩国产精品| 亚洲一区二区精品视频| 夜色激情一区二区| 欧美精品激情blacked18| 日韩一二三区视频| 亚洲美洲欧洲综合国产一区| 欧美在线视频一区| 国产亚洲毛片| 久热国产精品| 美女脱光内衣内裤视频久久网站| 亚洲国产二区| 亚洲欧洲偷拍精品| 欧美日韩在线另类| 亚洲香蕉成视频在线观看| 亚洲午夜精品国产| 国产色婷婷国产综合在线理论片a| 久久精品国语| 久久综合九色欧美综合狠狠| 亚洲日本乱码在线观看| 亚洲日本国产| 国产精品麻豆成人av电影艾秋| 久久激情视频| 久久影院午夜论| 一本久久综合亚洲鲁鲁| 在线一区二区三区做爰视频网站| 国产精品成人v| 久久久高清一区二区三区| 久久一区亚洲| 夜夜嗨av一区二区三区网站四季av | 香蕉久久夜色精品| 久久精品免费播放| 一本色道**综合亚洲精品蜜桃冫| 亚洲视频高清| 在线观看国产欧美| 日韩视频免费观看高清完整版| 国产酒店精品激情|