亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? chap04.htm

?? Thinking in Java, 2nd edition
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
}</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Now if you say:

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I31' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I32>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#0000ff>new</font> Bush();</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">the compiler will complain that it cannot
find a constructor that matches. It&#8217;s as if when you don&#8217;t put in
any constructors, the compiler says &#8220;You are bound to need <I>some</I>
constructor, so let me make one for you.&#8221; But if you write a constructor,
the compiler says &#8220;You&#8217;ve written a constructor so you know what
you&#8217;re doing; if you didn&#8217;t put in a default it&#8217;s because you
meant to leave it out.&#8221;

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I32' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I33>
</FONT><A NAME="_Toc375545280"></A><A NAME="_Toc481064575"></A><BR></P></DIV>
<A NAME="Heading170"></A><FONT FACE = "Verdana"><H3 ALIGN="LEFT">
The <A NAME="Index406"></A>this keyword</H3></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">If you have two objects of the same type
called <B>a</B> and <B>b</B>, you might wonder how it is that you can call a
method <B>f(&#160;)</B> for both those objects:

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I33' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I34>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#0000ff>class</font> Banana { <font color=#0000ff>void</font> f(<font color=#0000ff>int</font> i) { <font color=#009900>/* ... */</font> } }
Banana a = <font color=#0000ff>new</font> Banana(), b = <font color=#0000ff>new</font> Banana();
a.f(1);
b.f(2);</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">If there&#8217;s only one method called
<B>f(&#160;)</B>, how can that method know whether it&#8217;s being called for
the object <B>a</B> or <B>b</B>? 

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I34' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I35>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">To allow you to write the code in a
convenient object-oriented syntax in which you &#8220;send a message to an
object,&#8221; the compiler does some undercover work for you. There&#8217;s a
secret first argument passed to the method <B>f(&#160;)</B>, and that argument
is the reference to the object that&#8217;s being manipulated. So the two method
calls above become something like:

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I35' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I36>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE>Banana.f(a,1);
Banana.f(b,2);</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This is internal and you can&#8217;t
write these expressions and get the compiler to accept them, but it gives you an
idea of what&#8217;s happening.

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I36' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I37>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Suppose you&#8217;re inside a method and
you&#8217;d like to get the reference to the current object. Since that
reference is passed <I>secretly</I> by the compiler, there&#8217;s no identifier
for it. However, for this purpose there&#8217;s a keyword: <B>this</B>. The
<B>this</B> keyword&#8212;which can be used only inside a method&#8212;produces
the reference to the object the method has been called for. You can treat this
reference just like any other object reference. Keep in mind that if
you&#8217;re calling a method of your class from within another method of your
class, you don&#8217;t need to use <B>this</B>; you simply call the method. The
current <B>this</B> reference is automatically used for the other method. Thus
you can say: 
</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I37' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I38>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#0000ff>class</font> Apricot {
  <font color=#0000ff>void</font> pick() { <font color=#009900>/* ... */</font> }
  <font color=#0000ff>void</font> pit() { pick(); <font color=#009900>/* ... */</font> }
}</PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Inside <B>pit(&#160;)</B>, you
<I>could</I> say <B>this.pick(&#160;)</B> but there&#8217;s no need to. The
compiler does it for you automatically. The <B>this</B> keyword is used only for
those special cases in which you need to explicitly use the reference to the
current object. For example, it&#8217;s often used in <B>return</B> statements
when you want to return the reference to the current object:

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I38' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I39>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//: c04:Leaf.java</font>
<font color=#009900>// Simple use of the "this" keyword.</font>

<font color=#0000ff>public</font> <font color=#0000ff>class</font> Leaf {
  <font color=#0000ff>int</font> i = 0;
  Leaf increment() {
    i++;
    <font color=#0000ff>return</font> <font color=#0000ff>this</font>;
  }
  <font color=#0000ff>void</font> print() {
    System.out.println(<font color=#004488>"i = "</font> + i);
  }
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>void</font> main(String[] args) {
    Leaf x = <font color=#0000ff>new</font> Leaf();
    x.increment().increment().increment().print();
  }
} <font color=#009900>///:~</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Because <B>increment(&#160;)</B> returns
the reference to the current object via the <B>this</B> keyword, multiple
operations can easily be performed on the same object.

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I39' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I40>
</FONT><BR></P></DIV>
<A NAME="Heading171"></A><FONT FACE = "Verdana"><H4 ALIGN="LEFT">
Calling constructors from constructors<BR><A NAME="Index407"></A></H4></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">When you write several constructors for a
class, there are times when you&#8217;d like to call one constructor from
another to avoid duplicating code. You can do this using the <B>this</B>
keyword.  
</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I40' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I41>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Normally, when you say <B>this</B>, it is
in the sense of &#8220;this object&#8221; or &#8220;the current object,&#8221;
and by itself it produces the reference to the current object. In a constructor,
the <B>this</B> keyword takes on a different meaning when you give it an
argument list: it makes an explicit call to the constructor that matches that
argument list. Thus you have a straightforward way to call other constructors:

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I41' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I42>
</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//: c04:Flower.java</font>
<font color=#009900>// Calling constructors with "this."</font>

<font color=#0000ff>public</font> <font color=#0000ff>class</font> Flower {
  <font color=#0000ff>int</font> petalCount = 0;
  String s = <font color=#0000ff>new</font> String(<font color=#004488>"null"</font>);
  Flower(<font color=#0000ff>int</font> petals) {
    petalCount = petals;
    System.out.println(
      <font color=#004488>"Constructor w</font><font color=#004488>/ int arg only, petalCount= "</font>
      + petalCount);
  }
  Flower(String ss) {
    System.out.println(
      <font color=#004488>"Constructor w</font><font color=#004488>/ String arg only, s="</font> + ss);
    s = ss;
  }
  Flower(String s, <font color=#0000ff>int</font> petals) {
    <font color=#0000ff>this</font>(petals);
<font color=#009900>//!    this(s); // Can't call two!</font>
    <font color=#0000ff>this</font>.s = s; <font color=#009900>// Another use of "this"</font>
    System.out.println(<font color=#004488>"String &amp; int args"</font>);
  }
  Flower() {
    <font color=#0000ff>this</font>(<font color=#004488>"hi"</font>, 47);
    System.out.println(
      <font color=#004488>"default constructor (no args)"</font>);
  }
  <font color=#0000ff>void</font> print() {
<font color=#009900>//!    this(11); // Not inside non-constructor!</font>
    System.out.println(
      <font color=#004488>"petalCount = "</font> + petalCount + <font color=#004488>" s = "</font>+ s);
  }
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>void</font> main(String[] args) {
    Flower x = <font color=#0000ff>new</font> Flower();
    x.print();
  }
} <font color=#009900>///:~</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The constructor <B>Flower(String s, int
petals)</B> shows that, while you can call one constructor using <B>this</B>,
you cannot call two. In addition, the constructor call must be the first thing
you do or you&#8217;ll get a compiler error message.

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I42' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I43>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">This example also shows another way
you&#8217;ll see <B>this</B> used. Since the name of the argument <B>s </B>and
the name of the member data <B>s</B> are the same, there&#8217;s an ambiguity.
You can resolve it by saying <B>this.s</B> to refer to the member data.
You&#8217;ll often see this form used in Java code, and it&#8217;s used in
numerous places in this book.

</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I43' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I44>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">In <B>print(&#160;)</B> you can see that
the compiler won&#8217;t let you call a constructor from inside any method other
than a constructor. 
</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER4_I44' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER4_I45>
</FONT><BR></P></DIV>
<A NAME="Heading172"></A><FONT FACE = "Verdana"><H4 ALIGN="LEFT">
The meaning of static<BR><A NAME="Index408"></A></H4></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">With the <B>this </B>keyword in mind, you
can more fully understand what it means to make a
<A NAME="Index409"></A><A NAME="Index410"></A>method <B>static</B>. It means
that there is no <B>this</B> for that particular method. You cannot call
non-<B>static</B> methods from inside <B>static</B>
methods</FONT><A NAME="fnB28" HREF="#fn28">[28]</A><FONT FACE="Georgia">
(although the reverse is possible), and you can call a <B>static</B> method for

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产剧情一区二区| 色综合久久六月婷婷中文字幕| 中文一区二区在线观看| 色综合天天综合| 久久精品国产亚洲高清剧情介绍| 亚洲欧洲精品一区二区三区 | 免费在线观看视频一区| 国产精品天美传媒沈樵| 91精品国产一区二区三区香蕉| 成人午夜免费电影| 韩国毛片一区二区三区| 日韩精彩视频在线观看| 亚洲美女区一区| 国产偷v国产偷v亚洲高清| 91麻豆精品国产综合久久久久久| av毛片久久久久**hd| 国产一区 二区| 日韩va亚洲va欧美va久久| 亚洲精品亚洲人成人网在线播放| 国产女人18毛片水真多成人如厕| 欧美成人一区二区三区片免费| 欧美在线三级电影| 一本到高清视频免费精品| 高清国产一区二区| 国产在线精品免费| 九色综合狠狠综合久久| 日本午夜精品一区二区三区电影| 亚洲综合区在线| 亚洲免费视频中文字幕| 成人欧美一区二区三区小说 | 天天综合网 天天综合色| 亚洲精品视频在线观看网站| 国产欧美精品国产国产专区| 久久夜色精品国产噜噜av| 日韩欧美色综合| 精品国产网站在线观看| 日韩精品一区二区三区在线播放| 日韩小视频在线观看专区| 欧美一级高清片| 欧美大片一区二区| 精品乱人伦小说| 久久综合色婷婷| 国产日产欧美精品一区二区三区| 久久久久久久久久看片| 国产欧美一区二区精品久导航| 久久久久久久综合狠狠综合| 国产欧美久久久精品影院| 国产精品美女一区二区三区 | 欧美视频中文字幕| 欧美体内she精视频| 欧美日韩国产大片| 91精品综合久久久久久| 日韩一区二区免费在线电影| 欧美zozo另类异族| 国产人久久人人人人爽| 国产精品二三区| 亚洲男帅同性gay1069| 亚洲综合无码一区二区| 日韩有码一区二区三区| 久久国产精品第一页| 国产黄色成人av| 99精品桃花视频在线观看| 色欧美88888久久久久久影院| 欧美色综合天天久久综合精品| 欧美精品乱码久久久久久| 久久女同互慰一区二区三区| 中文字幕日韩一区二区| 亚洲午夜精品17c| 精品一区二区三区在线视频| www.在线欧美| 欧美精品视频www在线观看 | 国产精品久久久久影视| 亚洲一区二区在线观看视频| 美女脱光内衣内裤视频久久影院| 国产98色在线|日韩| 在线观看日韩电影| 欧美不卡一二三| 亚洲精品久久久久久国产精华液| 日本美女一区二区三区视频| 国产精品夜夜嗨| 欧美亚洲国产bt| 久久久久国产免费免费| 亚洲国产视频一区| 国产精品性做久久久久久| 91成人免费网站| 亚洲精品一区二区三区影院 | 亚洲精品老司机| 黑人精品欧美一区二区蜜桃 | 国产乱子轮精品视频| 欧美亚洲图片小说| 国产亚洲精品福利| 婷婷一区二区三区| 成人国产一区二区三区精品| 日韩一区二区三区三四区视频在线观看| 日本一区二区三区电影| 日韩激情一区二区| 91日韩在线专区| 久久精品欧美一区二区三区麻豆 | 极品美女销魂一区二区三区| 91久久精品一区二区| 欧美精品一区二区三区在线播放| 一区二区三区免费看视频| 国产精一品亚洲二区在线视频| 欧美日韩一区高清| 国产精品麻豆一区二区| 久久99精品国产麻豆婷婷| 欧美性xxxxxxxx| 国产精品的网站| 国产美女在线观看一区| 欧美一区二区三区视频| 亚洲一区二区三区四区五区黄| 成人av在线影院| 久久青草欧美一区二区三区| 秋霞午夜鲁丝一区二区老狼| 日本精品视频一区二区| 国产精品美女久久久久久久久久久| 麻豆高清免费国产一区| 欧美色区777第一页| 亚洲免费观看高清在线观看| 国产成人免费高清| 久久网这里都是精品| 久久99国产精品免费| 91精品国产品国语在线不卡| 亚洲一区二区三区影院| 欧美这里有精品| 亚洲欧洲综合另类在线 | 日韩欧美一级二级| 美女脱光内衣内裤视频久久网站| 欧美日韩国产在线观看| 亚洲成av人片在www色猫咪| 色婷婷综合在线| 亚洲精品中文字幕在线观看| 色嗨嗨av一区二区三区| 亚洲欧美日韩国产一区二区三区 | 综合自拍亚洲综合图不卡区| 丁香激情综合五月| 国产精品色哟哟网站| eeuss鲁片一区二区三区在线观看| 国产欧美一区二区精品忘忧草| 国产成人精品亚洲777人妖| 久久久久久久电影| 东方aⅴ免费观看久久av| 中文字幕精品综合| 成人av网站免费观看| 国产精品欧美久久久久一区二区| 国产成人午夜高潮毛片| 国产精品精品国产色婷婷| 91亚洲永久精品| 一区二区不卡在线视频 午夜欧美不卡在| 91丨九色丨尤物| 亚洲一区二区三区不卡国产欧美| 欧美性做爰猛烈叫床潮| 日本视频中文字幕一区二区三区| 欧美一区二区三区四区高清| 国产在线不卡视频| 国产精品无码永久免费888| 91免费观看国产| 午夜精品久久久久影视| 欧美大片一区二区| 成人晚上爱看视频| 亚洲一区视频在线| 精品日韩一区二区三区| 春色校园综合激情亚洲| 亚洲四区在线观看| 欧美精选午夜久久久乱码6080| 狠狠色狠狠色综合日日91app| 国产精品日韩精品欧美在线| 色嗨嗨av一区二区三区| 美腿丝袜一区二区三区| 国产精品久久久久久久裸模| 欧美日韩国产高清一区二区 | 不卡一二三区首页| 一区二区三区高清不卡| 欧美α欧美αv大片| 一本一道综合狠狠老| 日本va欧美va瓶| 亚洲欧洲av另类| 日韩欧美中文一区二区| 91丨九色丨蝌蚪丨老版| 六月丁香综合在线视频| 亚洲九九爱视频| ww亚洲ww在线观看国产| 欧洲一区二区av| 国内精品国产成人国产三级粉色| 亚洲激情在线播放| 精品国产乱码久久久久久闺蜜| 9人人澡人人爽人人精品| 日欧美一区二区| 中文字幕中文字幕一区| 日韩精品一区二区三区四区| 97久久精品人人爽人人爽蜜臀| 麻豆国产欧美日韩综合精品二区 | 亚洲一区中文在线| 久久麻豆一区二区| 欧美日韩你懂的| av亚洲精华国产精华精| 久久国产精品免费| 亚洲福利视频三区| 国产精品高潮呻吟| 久久精品视频一区二区|