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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chap09.htm

?? Thinking in Java, 2nd edition
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
    <font color=#0000ff>private</font> <font color=#0000ff>int</font> mod = 10000;
    <font color=#0000ff>public</font> RandIntGenerator() {}
    <font color=#0000ff>public</font> RandIntGenerator(<font color=#0000ff>int</font> modulo) {
      mod = modulo;
    }
    <font color=#0000ff>public</font> <font color=#0000ff>int</font> next() { 
      <font color=#0000ff>return</font> r.nextInt() % mod; 
    }
  }
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>class</font> RandLongGenerator 
  <font color=#0000ff>implements</font> LongGenerator {
    <font color=#0000ff>public</font> <font color=#0000ff>long</font> next() { <font color=#0000ff>return</font> r.nextLong(); }
  }
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>class</font> RandFloatGenerator 
  <font color=#0000ff>implements</font> FloatGenerator {
    <font color=#0000ff>public</font> <font color=#0000ff>float</font> next() { <font color=#0000ff>return</font> r.nextFloat(); }
  }
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>class</font> RandDoubleGenerator 
  <font color=#0000ff>implements</font> DoubleGenerator {
    <font color=#0000ff>public</font> <font color=#0000ff>double</font> next() {<font color=#0000ff>return</font> r.nextDouble();}
  }
} <font color=#009900>///:~</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">To fill an array of elements using a
generator, the <B>fill(&#160;)</B> method takes a reference to an appropriate
generator <B>interface</B>, which has a <B>next(&#160;)</B> method that will
somehow produce an object of the right type (depending on how the interface is
implemented). The <B>fill(&#160;)</B> method simply calls <B>next(&#160;)</B>
until the desired range has been filled. Now you can create any generator by
implementing the appropriate <B>interface</B>, and use your generator with
<B>fill(&#160;)</B>. 
</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER9_I24' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER9_I25>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Random data generators are useful for
testing, so a set of inner classes is created to implement all the primitive
generator interfaces, as well as a <B>String</B> generator to represent
<B>Object</B>. You can see that <B>RandStringGenerator</B> uses
<B>RandCharGenerator</B> to fill an array of characters, which is then turned
into a <B>String</B>. The size of the array is determined by the constructor
argument. 
</backtalk:display>
[&nbsp;<a href='http://www.mindview.net/backtalk/CommentServlet?ID=TIJ3_CHAPTER9_I25' 
  target="_blank">Add&nbsp;Comment</a>&nbsp;]

<backtalk:display ID=TIJ3_CHAPTER9_I26>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">To generate numbers that aren&#8217;t too
large, <B>RandIntGenerator</B> defaults to a modulus of 10,000, but the
overloaded constructor allows you to choose a smaller value.

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

<backtalk:display ID=TIJ3_CHAPTER9_I27>
</FONT><BR></P></DIV>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">Here&#8217;s a program to test the
library, and to demonstrate how it is used:</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//: c09:TestArrays2.java</font>
<font color=#009900>// Test and demonstrate Arrays2 utilities</font>
<font color=#0000ff>import</font> com.bruceeckel.util.*;

<font color=#0000ff>public</font> <font color=#0000ff>class</font> TestArrays2 {
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>void</font> main(String[] args) {
    <font color=#0000ff>int</font> size = 6;
    <font color=#009900>// Or get the size from the command line:</font>
    <font color=#0000ff>if</font>(args.length != 0)
      size = Integer.parseInt(args[0]);
    <font color=#0000ff>boolean</font>[] a1 = <font color=#0000ff>new</font> <font color=#0000ff>boolean</font>[size];
    <font color=#0000ff>byte</font>[] a2 = <font color=#0000ff>new</font> <font color=#0000ff>byte</font>[size];
    <font color=#0000ff>char</font>[] a3 = <font color=#0000ff>new</font> <font color=#0000ff>char</font>[size];
    <font color=#0000ff>short</font>[] a4 = <font color=#0000ff>new</font> <font color=#0000ff>short</font>[size];
    <font color=#0000ff>int</font>[] a5 = <font color=#0000ff>new</font> <font color=#0000ff>int</font>[size];
    <font color=#0000ff>long</font>[] a6 = <font color=#0000ff>new</font> <font color=#0000ff>long</font>[size];
    <font color=#0000ff>float</font>[] a7 = <font color=#0000ff>new</font> <font color=#0000ff>float</font>[size];
    <font color=#0000ff>double</font>[] a8 = <font color=#0000ff>new</font> <font color=#0000ff>double</font>[size];
    String[] a9 = <font color=#0000ff>new</font> String[size];
    Arrays2.fill(a1, 
      <font color=#0000ff>new</font> Arrays2.RandBooleanGenerator());
    Arrays2.print(a1);
    Arrays2.print(<font color=#004488>"a1 = "</font>, a1);
    Arrays2.print(a1, size/3, size/3 + size/3);
    Arrays2.fill(a2,
      <font color=#0000ff>new</font> Arrays2.RandByteGenerator());
    Arrays2.print(a2);
    Arrays2.print(<font color=#004488>"a2 = "</font>, a2);
    Arrays2.print(a2, size/3, size/3 + size/3);
    Arrays2.fill(a3,
      <font color=#0000ff>new</font> Arrays2.RandCharGenerator());
    Arrays2.print(a3);
    Arrays2.print(<font color=#004488>"a3 = "</font>, a3);
    Arrays2.print(a3, size/3, size/3 + size/3);
    Arrays2.fill(a4,
      <font color=#0000ff>new</font> Arrays2.RandShortGenerator());
    Arrays2.print(a4);
    Arrays2.print(<font color=#004488>"a4 = "</font>, a4);
    Arrays2.print(a4, size/3, size/3 + size/3);
    Arrays2.fill(a5,
      <font color=#0000ff>new</font> Arrays2.RandIntGenerator());
    Arrays2.print(a5);
    Arrays2.print(<font color=#004488>"a5 = "</font>, a5);
    Arrays2.print(a5, size/3, size/3 + size/3);
    Arrays2.fill(a6,
      <font color=#0000ff>new</font> Arrays2.RandLongGenerator());
    Arrays2.print(a6);
    Arrays2.print(<font color=#004488>"a6 = "</font>, a6);
    Arrays2.print(a6, size/3, size/3 + size/3);
    Arrays2.fill(a7,
      <font color=#0000ff>new</font> Arrays2.RandFloatGenerator());
    Arrays2.print(a7);
    Arrays2.print(<font color=#004488>"a7 = "</font>, a7);
    Arrays2.print(a7, size/3, size/3 + size/3);
    Arrays2.fill(a8,
      <font color=#0000ff>new</font> Arrays2.RandDoubleGenerator());
    Arrays2.print(a8);
    Arrays2.print(<font color=#004488>"a8 = "</font>, a8);
    Arrays2.print(a8, size/3, size/3 + size/3);
    Arrays2.fill(a9,
      <font color=#0000ff>new</font> Arrays2.RandStringGenerator(7));
    Arrays2.print(a9);
    Arrays2.print(<font color=#004488>"a9 = "</font>, a9);
    Arrays2.print(a9, size/3, size/3 + size/3);
  }
} <font color=#009900>///:~</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The <B>size</B> parameter has a default
value, but you can also set it from the command line.

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

<backtalk:display ID=TIJ3_CHAPTER9_I28>
</FONT><A NAME="_Toc481064669"></A><BR></P></DIV>
<A NAME="Heading282"></A><FONT FACE = "Verdana"><H3 ALIGN="LEFT">
Filling an array</H3></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The Java standard library <B>Arrays</B>
also has a <B>fill(&#160;)</B> method, but that is rather trivial&#8212;it only
duplicates a single value into each location, or in the case of objects, copies
the same reference into each location. Using <B>Arrays2.print(&#160;)</B>, the
<A NAME="Index875"></A><B>Arrays.fill(&#160;)</B> methods can be easily
demonstrated:</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//: c09:FillingArrays.java</font>
<font color=#009900>// Using Arrays.fill()</font>
<font color=#0000ff>import</font> com.bruceeckel.util.*;
<font color=#0000ff>import</font> java.util.*;

<font color=#0000ff>public</font> <font color=#0000ff>class</font> FillingArrays {
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>void</font> main(String[] args) {
    <font color=#0000ff>int</font> size = 6;
    <font color=#009900>// Or get the size from the command line:</font>
    <font color=#0000ff>if</font>(args.length != 0)
      size = Integer.parseInt(args[0]);
    <font color=#0000ff>boolean</font>[] a1 = <font color=#0000ff>new</font> <font color=#0000ff>boolean</font>[size];
    <font color=#0000ff>byte</font>[] a2 = <font color=#0000ff>new</font> <font color=#0000ff>byte</font>[size];
    <font color=#0000ff>char</font>[] a3 = <font color=#0000ff>new</font> <font color=#0000ff>char</font>[size];
    <font color=#0000ff>short</font>[] a4 = <font color=#0000ff>new</font> <font color=#0000ff>short</font>[size];
    <font color=#0000ff>int</font>[] a5 = <font color=#0000ff>new</font> <font color=#0000ff>int</font>[size];
    <font color=#0000ff>long</font>[] a6 = <font color=#0000ff>new</font> <font color=#0000ff>long</font>[size];
    <font color=#0000ff>float</font>[] a7 = <font color=#0000ff>new</font> <font color=#0000ff>float</font>[size];
    <font color=#0000ff>double</font>[] a8 = <font color=#0000ff>new</font> <font color=#0000ff>double</font>[size];
    String[] a9 = <font color=#0000ff>new</font> String[size];
    Arrays.fill(a1, <font color=#0000ff>true</font>);
    Arrays2.print(<font color=#004488>"a1 = "</font>, a1);
    Arrays.fill(a2, (<font color=#0000ff>byte</font>)11);
    Arrays2.print(<font color=#004488>"a2 = "</font>, a2);
    Arrays.fill(a3, 'x');
    Arrays2.print(<font color=#004488>"a3 = "</font>, a3);
    Arrays.fill(a4, (<font color=#0000ff>short</font>)17);
    Arrays2.print(<font color=#004488>"a4 = "</font>, a4);
    Arrays.fill(a5, 19);
    Arrays2.print(<font color=#004488>"a5 = "</font>, a5);
    Arrays.fill(a6, 23);
    Arrays2.print(<font color=#004488>"a6 = "</font>, a6);
    Arrays.fill(a7, 29);
    Arrays2.print(<font color=#004488>"a7 = "</font>, a7);
    Arrays.fill(a8, 47);
    Arrays2.print(<font color=#004488>"a8 = "</font>, a8);
    Arrays.fill(a9, <font color=#004488>"Hello"</font>);
    Arrays2.print(<font color=#004488>"a9 = "</font>, a9);
    <font color=#009900>// Manipulating ranges:</font>
    Arrays.fill(a9, 3, 5, <font color=#004488>"World"</font>);
    Arrays2.print(<font color=#004488>"a9 = "</font>, a9);
  }
} <font color=#009900>///:~</font></PRE></FONT></BLOCKQUOTE>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">You can either fill the entire array,
or&#8212;as the last two statements show&#8212;a range of elements. But since
you can only provide a single value to use for filling using
<B>Arrays.fill(&#160;)</B>, the <B>Arrays2.fill(&#160;)</B> methods produce much
more interesting results.

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

<backtalk:display ID=TIJ3_CHAPTER9_I29>
</FONT><A NAME="_Toc481064670"></A><BR></P></DIV>
<A NAME="Heading283"></A><FONT FACE = "Verdana"><H3 ALIGN="LEFT">
Copying an array<BR><A NAME="Index876"></A><A NAME="Index877"></A></H3></FONT>
<DIV ALIGN="LEFT"><P><FONT FACE="Georgia">The Java standard library provides a
<B>static </B>method, <A NAME="Index878"></A><B>System.arraycopy(&#160;)</B>,
which can make much faster copies of an array than if you use a <B>for</B> loop
to perform the copy by hand. <B>System.arraycopy(&#160;) </B>is overloaded to
handle all types. Here&#8217;s an example that manipulates arrays of
<B>int</B>:</FONT><BR></P></DIV>

<BLOCKQUOTE><FONT SIZE = "+1"><PRE><font color=#009900>//: c09:CopyingArrays.java</font>
<font color=#009900>// Using System.arraycopy()</font>
<font color=#0000ff>import</font> com.bruceeckel.util.*;
<font color=#0000ff>import</font> java.util.*;

<font color=#0000ff>public</font> <font color=#0000ff>class</font> CopyingArrays {
  <font color=#0000ff>public</font> <font color=#0000ff>static</font> <font color=#0000ff>void</font> main(String[] args) {
    <font color=#0000ff>int</font>[] i = <font color=#0000ff>new</font> <font color=#0000ff>int</font>[25];
    <font color=#0000ff>int</font>[] j = <font color=#0000ff>new</font> <font color=#0000ff>int</font>[25];
    Arrays.fill(i, 47);
    Arrays.fill(j, 99);
    Arrays2.print(<font color=#004488>"i = "</font>, i);
    Arrays2.print(<font color=#004488>"j = "</font>, j);
    System.arraycopy(i, 0, j, 0, i.length);
    Arrays2.print(<font color=#004488>"j = "</font>, j);
    <font color=#0000ff>int</font>[] k = <font color=#0000ff>new</font> <font color=#0000ff>int</font>[10];
    Arrays.fill(k, 103);
    System.arraycopy(i, 0, k, 0, k.length);
    Arrays2.print(<font color=#004488>"k = "</font>, k);
    Arrays.fill(k, 103);
    System.arraycopy(k, 0, i, 0, k.length);
    Arrays2.print(<font color=#004488>"i = "</font>, i);
    <font color=#009900>// Objects:</font>
    Integer[] u = <font color=#0000ff>new</font> Integer[10];
    Integer[] v = <font color=#0000ff>new</font> Integer[5];
    Arrays.fill(u, <font color=#0000ff>new</font> Integer(47));
    Arrays.fill(v, 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月综合激情婷婷六月色窝| 日本美女视频一区二区| 欧美日韩黄视频| 国产精品综合一区二区| 亚洲成人午夜影院| 国产日产精品1区| 91精品国产综合久久精品麻豆| 国产精品一区二区果冻传媒| 日韩影院精彩在线| 1024精品合集| 国产欧美精品一区二区色综合朱莉| 欧美影院一区二区三区| 国产成人午夜精品影院观看视频 | 日韩亚洲欧美成人一区| 99热这里都是精品| 国产一区二区三区在线观看免费视频 | 精品一区二区久久| 亚洲乱码国产乱码精品精小说| ww亚洲ww在线观看国产| 91精品国产麻豆| 欧美视频一区二区三区| 99久久免费视频.com| 成人av电影观看| 亚洲成人一区二区在线观看| 综合精品久久久| 欧美一区二区网站| 色综合欧美在线视频区| 成人美女视频在线观看18| 久久精品99久久久| 偷拍一区二区三区四区| 亚洲欧美日韩系列| 国产精品卡一卡二| 久久久国产午夜精品| 欧美一区二区三区视频在线观看| 欧美三级中文字幕| 91丨九色丨国产丨porny| 成人激情午夜影院| 国产精品一区三区| 国产精品一区二区你懂的| 国产在线不卡视频| 国产乱子伦视频一区二区三区| 精品制服美女久久| 极品少妇一区二区三区精品视频| 免费观看一级欧美片| 日本成人在线看| 欧美aⅴ一区二区三区视频| 午夜精品一区在线观看| 亚洲一区二区精品视频| 亚洲777理论| 五月激情综合色| 丝瓜av网站精品一区二区| 视频一区二区国产| 麻豆精品一区二区综合av| 久久99热狠狠色一区二区| 精品夜夜嗨av一区二区三区| 日本va欧美va欧美va精品| 久久精品国产99国产| 国产精品自拍在线| 高清免费成人av| 色综合久久综合| 欧美日韩成人一区二区| 日韩精品中文字幕一区| 精品国产伦一区二区三区观看方式| 国产亚洲欧美一级| 国产精品久久久久影院色老大| 亚洲人成在线播放网站岛国| 亚洲成人一二三| 国产一区中文字幕| 99久久婷婷国产综合精品电影| 精品视频123区在线观看| 91精品国产综合久久久久| 久久免费的精品国产v∧| 国产精品美女视频| 亚洲综合在线观看视频| 日韩av网站免费在线| 国产精品资源站在线| 色综合久久综合网| 日韩一区二区免费在线观看| 中文字幕av在线一区二区三区| 亚洲女女做受ⅹxx高潮| 日韩精品一二三| 成人性生交大片免费看在线播放 | 久久久久久久久岛国免费| 国产精品欧美久久久久无广告| 一区二区高清免费观看影视大全| 免费看日韩精品| 不卡的电视剧免费网站有什么| 欧美精品三级在线观看| 久久久三级国产网站| 亚洲美女视频在线观看| 老司机精品视频导航| 91亚洲国产成人精品一区二三| 日韩视频一区二区三区| 中文字幕色av一区二区三区| 另类小说综合欧美亚洲| 91久久免费观看| 久久久久久久综合日本| 亚洲成av人片在线| av电影天堂一区二区在线观看| 日韩欧美一区二区免费| 一区二区三区四区视频精品免费 | 美女视频黄 久久| 91在线一区二区| 精品成人免费观看| 亚洲午夜电影在线| 成人看片黄a免费看在线| 欧美一区二区三区视频| 亚洲精品五月天| 成人伦理片在线| 久久麻豆一区二区| 免费观看久久久4p| 欧美亚洲高清一区二区三区不卡| 亚洲国产成人午夜在线一区| 精品一二三四区| 欧美一区二区成人| 亚洲国产成人av| 色综合天天做天天爱| 中文字幕av资源一区| 国产精品自在在线| 欧美mv日韩mv国产网站app| 午夜国产不卡在线观看视频| 一本到三区不卡视频| 另类综合日韩欧美亚洲| 中文乱码免费一区二区| 精品午夜久久福利影院| 在线观看日韩高清av| 国产精品免费观看视频| 国产精品99久久久久久久vr| 日韩精品一区二区三区四区 | 国产一区中文字幕| 日韩一区二区免费视频| 日本 国产 欧美色综合| 欧美电影一区二区三区| 亚洲国产欧美在线人成| 欧美在线观看视频一区二区| 亚洲精品你懂的| 91在线观看地址| 亚洲色图第一区| 91啪九色porn原创视频在线观看| 亚洲欧洲精品一区二区精品久久久| 国产高清在线观看免费不卡| 国产日本一区二区| 国产99久久精品| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 国产伦精品一区二区三区免费迷| 久久亚洲精华国产精华液| 激情av综合网| 久久久不卡网国产精品二区| 国产99久久久久久免费看农村| 亚洲国产经典视频| 97超碰欧美中文字幕| 亚洲一区自拍偷拍| 91精品国产综合久久福利| 美女性感视频久久| 久久先锋影音av| 99久久国产综合精品色伊 | 蜜臀久久久99精品久久久久久| 欧美成人三级在线| 国产精品一区二区三区99| 中文字幕一区日韩精品欧美| 色爱区综合激月婷婷| 日韩综合在线视频| 久久综合久久综合亚洲| 成年人国产精品| 亚洲va欧美va人人爽午夜| 91精品午夜视频| 国产**成人网毛片九色 | 精品亚洲成av人在线观看| 久久久久高清精品| 99re成人在线| 午夜私人影院久久久久| 精品国产乱码久久久久久1区2区| 粉嫩av亚洲一区二区图片| 亚洲综合激情另类小说区| 日韩天堂在线观看| 成人午夜电影久久影院| 亚洲国产精品久久久久秋霞影院| 欧美成人一区二区三区在线观看| 成人免费毛片高清视频| 一卡二卡欧美日韩| 亚洲一区在线播放| 精品国产一二三区| 91蜜桃免费观看视频| 久久国产福利国产秒拍| 日韩美女视频19| 日韩精品一区二区三区在线| 一本高清dvd不卡在线观看| 精品无人区卡一卡二卡三乱码免费卡| 中文字幕一区二区三区乱码在线| 91精品视频网| 91免费看视频| 加勒比av一区二区| 亚洲一区电影777| 国产喂奶挤奶一区二区三区| 欧美揉bbbbb揉bbbbb| 成人在线综合网站| 青青草伊人久久| 一区二区高清免费观看影视大全| 久久麻豆一区二区| 91精品国产一区二区三区|