⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tij0118.html

📁 学习java的经典书籍
💻 HTML
字号:
<html><body>

<table width="100%"><tr>
<td>
<a href="http://www.bruceeckel.com/javabook.html">Bruce Eckel's Thinking in Java</a>
</td>
<td align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0117.html">Prev</a> | <a href="tij0119.html">Next</a>
</td>
</tr></table>
<hr>

<H2 ALIGN=LEFT>
Exercises</H2>
<OL>
<LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Open
a text file so that you can read the file one line at a time. Read each line as
a 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>String
</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">and
place that 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>String
</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">object
into a 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Vector</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
Print out all of the lines in the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Vector</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
in reverse order.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Modify
Exercise 1 so that the name of the file you read is provided as a command-line
argument.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Modify
Exercise 2 to also open a text file so you can write text into it. Write the
lines in the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Vector</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
along with line numbers, out to the file.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Modify
Exercise 2 to force all the lines in the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Vector</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
to upper case and send the results to 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>System.out</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Modify
Exercise 2 to take additional arguments of words to find in the file. Print out
any lines in which the words match.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">In
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Blips.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
copy the file and rename it to 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>BlipCheck.java
</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">and
rename the class 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Blip2</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
to 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>BlipCheck
</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">(making
it 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>public</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
in the process). Remove the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>//!</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
marks in the file and execute the program including the offending lines. Next,
comment out the default constructor for 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>BlipCheck</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">.
Run it and explain why it works.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">In
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Blip3.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
comment out the two lines after the phrases &#8220;You must do this:&#8221; and
run the program. Explain the result and why it differs from when the two lines
are in the program.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Convert
the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>SortedWordCount.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
program to use the Java 1.
</FONT></OL><DIV ALIGN=LEFT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">1<A NAME="Index1352"></A>
IO Streams.
</FONT><P></DIV>
<OL>
<LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">Repair
the program 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>CADState.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
as described in the text.
</FONT><LI><FONT FACE="Carmina Md BT" SIZE=5 COLOR="Black">	</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">(Intermediate)
In Chapter 7, locate the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>GreenhouseControls.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
example, which consists of three files. In 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>GreenhouseControls.java</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">,
the 
</FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black"><B>Restart(&#160;)</B></FONT><FONT FACE="Carmina Md BT" SIZE=3 COLOR="Black">
inner class has a hard-coded set of events. Change the program so that it reads
the events and their relative times from a text file. (Challenging: Use a
factory method from Chapter 16 to build the events.)
</FONT></OL><DIV ALIGN=LEFT><FONT FACE="Da Vinci Extras" SIZE=39 COLOR="Black">9</FONT><a name="Chapter_12"></a><a name="_Toc375545404"></a><a name="_Toc407441455"></a><a name="_Toc408018644"></a><P></DIV>

<div align="right">
<a href="tij_c.html">Contents</a> | <a href="tij0117.html">Prev</a> | <a href="tij0119.html">Next</a>
</div>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -