Skip to main content

Ivor Horton's Beginning Java 2, JDK 5 Edition

Ivor Horton's Beginning Java 2, JDK 5 Edition

Ivor Horton

ISBN: 978-0-764-57943-1

Jan 2005

1512 pages

Select type: E-Book

$32.99

Description

What is this book about?

This book is a comprehensive introduction to the Java programming language, updated thoroughly (more than 35% new and updated) for the latest SDK 1.5 release. This book shows readers how to build real-world Java applications using the Java SDK. No previous programming experience is required. The author uses numerous step-by-step programming examples to guide readers through the ins and outs of Java development. In addition to fully covering new features of SDK 1.5, such as generic types, the author has also added new chapters on Java database programming with JDBC and Java programming with XML.

About the Author.

Foreword.

Acknowledgments.

Introduction.

Chapter 1: Introducing Java.

Chapter 2: Programs, Data, Variables, and Calculation.

Chapter 3: Loops and Logic.

Chapter 4: Arrays and Strings.

Chapter 5: Defining Classes.

Chapter 6: Extending Classes and Inheritance.

Chapter 7: Exceptions.

Chapter 8: Understanding Streams.

Chapter 9: Accessing Files and Directories.

Chapter 10: Writing Files.

Chapter 11: Reading Files.

Chapter 12: Serializing Objects.

Chapter 13: Generic Class Types.

Chapter 14: The Collections Framework.

Chapter 15: A Collection of Useful Classes.

Chapter 16: Threads.

Chapter 17: Creating Windows.

Chapter 18: Handling Events.

Chapter 19: Drawing in a Window.

Chapter 20: Extending the GUI.

Chapter 21: Filing and Printing Documents.

Chapter 22: Java and XML.

Chapter 23: Creating and Modifying XML Documents.

Chapter 24: Talking to Databases.

Chapter 25: The JDBC in Action.

Appendix A: Keywords.

Appendix B: Computer Arithmetic.

Index.

  • Ivor Horton is a leading author of computer programming language tutorials; his Beginning Java has sold more than 150,000 copies in all editions.
  • The author is known for his unique tutorial style, readily accessible to both novice and experienced programmers.
  • The book will include exercises and solutions.
  • The latest edition fully covers the most recent release of Java, JDK 5, and adds new coverage of database and XML programming.
Update for Java SE 6
Code downloads for this title are available here.
Download
Code from the book in .rar format.
Here is the code stored in the .rar archive format at ~1/5 the size of the .zip version. If your compression software does not support the .rar format you will need a program like WinRAR to uncompress the files. Get a trial version of WinRAR at www.rarlabs.com.
Download
Code from the book in .zip format.
Download
Solutions to the Exercises in .rar format.
Here are the solutions stored in the .rar archive format at ~1/4 the size of the .zip version. If your compression software does not support the .rar format you will need a program like WinRAR to uncompress the files. Get a trial version of WinRAR at www.rarlabs.com.
Download
Solutions to the Exercises in .zip format.
Download
Error in Code - LinkedList.java
The corrected code for the deleteItem() method in the LinkedList class is attached.
Download
ChapterPageDetailsDatePrint Run
Figures 1-4 and 1-5Error in Code
In both figures 1-4 and 1-5 the closing brace should be a right brace, "}"
06/02/2010

18Figure 1-7
The putHatOn() method appears twice. In place of the duplicate putHatOn() method, there should be a definition for the takeHatOff() method, as follows:
// Method to take the hat off
public void takeHatOff()   {
     hatOn  =  false;                 // Record hat status as off
}
1/22/05

19Figure 1-7
In figure 1-7 the first line of the constructor definition and the comment preceding it should have CowboyHat in place of Hat, so they should be:

// Constructor to create a CowboyHat object
public CowboyHat(String person, int theSize)
3/27/05

36Bottom right table entry
In the bottom right table entry the last sentence has a superfluous right parenthesis so it should read:
The smallest non-zero value that you can have is roughly ±4.9x10-324.
1/22/05

37Last sentence in paragraph at top of page
In the last sentence in the paragraph at the top of the page "9.0E-28" should read 9.0E-28.
1/22/05

43Figure 2-3
In Figure 2-3 the first line of the main() method should be:
public static void main(String[] args) {
1/22/05

452nd to Last Sentence, 2nd to Last Paragraph
The second to last sentence in the second to last paragraph should read:

"When the dividend is a negative integer of the largest possible magnitude and the divisor is -1 the result is the same as the dividend, which is negative and therefore violates the rule."
3/27/05

50Last sentence at bottom of page
The last sentence at the bottom of the page has a symbol missing and is unclear. It should be replaced by the following:
For the more mathematically minded the result, r, of the expression a%b, where a and b are non-zero floating-point values, is defined by the expression a-(n.b). The value n has the same sign as a/b and is the largest possible integer such that a/n is less than or equal to the true quotient a/b.
1/22/05

552nd to last sentence in the 1st paragraph
The second to last sentence in the first paragraph contains a left parenthesis where the symbol p should appear. It should therefore read:
The Math class also defines double values for e and p, which you can access as Math.E and Math.PI respectively.
1/22/05

58Last code line for "Try It Out: The Math Class"
There is a discrepancy between the code for "Try It Out: The Math Class" and the sample output given. The last code line should be:
System.out.println("The radius of a pond with area " + pondArea + " square feet is " + feet + " feet " + inches + " inches");
1/22/05

58Symbols in "How It Works" section
Symbols in the second paragraph in the "How It Works" section are not displayed correctly. The second sentence in this paragraph should read:
Since the area of a circle with radius r is given by the formula pr2, the radius must be Ö(area/p), so you specify the argument to the sqrt() method as the expression pondArea/Math.PI, where Math.PI references the value of p that is defined in the Math class:
1/22/05

62Error in "How it Works"
In the paragraph in the "How It Works" section following the three lines of code:

"letter1+2" should be "letter1+1".
3/21/05

66Error in Table
In the second table, where indicator is 0xFF09:
the result(indicators & mask value)is printed:
0x0004

should be:
0x00
11/12/06

702nd sentence below 1st line of code
The second sentence in the text below the first line of code has some zeros missing. It should read:
The literal 0xFF is type int, so it is the binary value 0000 0000 0000 0000 0000 0000 1111 1111.
1/22/05

72Figure 2-7
The second to last expression in Figure 2-7 should assign the result of the shift operation to x, so it should be:

x = value >> 16; // Extract x from value (positive or negative)
3/27/05

76-77Error in Code
The output on page 77 does not correspond to the code on page 76.

There is a spurious \n character in the line of code third from bottom of page 76. The line should be:

System.out.println("Bit count in number: " + bitCount(number));
11/22/05

90Figure 3-2
In Figure 3-2 the right braces have erroneously been printed as right parentheses. The code should read:

if(expression) {
statement1;
} else {
statement2;
}>br? next_statement;
3/21/05

94Missing ")"
There is a right parenthesis missing from the if statement that reads:

if(season.equals(Season.spring) {

so it should read:

if(season.equals(Season.spring)) {
1/22/05

105In the flowchart in Figure 3-5
The arrow leaving the block containing "Do value2 thing" should go to the block containing "Do default Action" and not direct to the block containing "Continue the Program".
1/22/05

105Missing spaces in first "} else line
The first "} else {" in the LetterCheck program is not indented correctly. It should be indented two more space so that the '}' aligns with the 'i' in the immediately preceding "if".
1/22/05

105Figure 3-5, Character Missing
In Figure 3-5 the last character is missing from the case label. It should be:

switch(expression){
case value1:
//Do value1 thing

case value2:
//Do value2 thing

...
default:
// Do default action


}

// Continue the program
3/21/05

129Typos in Figure 3-9
In Figure 3-9 the three occurrences of "breaks our beyond" should be "breaks out beyond".
1/22/05

134Error in Text
2. When testing whether an integer is a prime, it is sufficient to try to divide by integers up to the square root of the number being tested.

should be:
When testing whether an integer is a prime, it is sufficient to try to divide by integers up to and including the square root of the number being tested.
02/25/07

137Wrong symbols in Figure 4-1
In Figure 4-1 the labels "primes(0)", "primes(1)", etc. should be "primes[0]", primes[1]", etc.
1/22/05

139Wrong labels in Figure 4-2
In Figure 4-2 the labels on the rightmost two array elements in the lower array should be "primes[48]" and "primes[49]".
1/22/05

150Wrong label in Figure 4-5
In Figure 4-5 the second element in the second row should be labeled "samples[1][1]" instead of "samples[2][1]"
1/22/05

156Error in Code
String[] colors =
{"red","orange","yellow","green","blue","indigo",violet"};

violet"
should be :
"violet"
08/05/08

174Error in Text
Line after the code snippet in the middle of the page:

"Then the expression String1.startsWith("Ides", 4) will have the value true."
Should be changed to:
"Then the expression string1.startsWith("Ides", 4) will have the value true."

Note the lowercase 's' of string1.
1/13/06

190Error in code
In the code fragment at the bottom of the page:
long number = 999;

should be:
long number = 99L;
09/05/06

202Error in Text
On page 202, 2nd para, last sentence, the "(" should be "pi".
2-23-11

203Pi represented as Left Parenthesis, Top of Page
In the last sentence in the paragraph at the top of the page π has been printed as a left parenthesis. The sentence should read:

The Math class also contains some class variables containing useful mathematical constants such as e and π
3/21/05

203Pi represented as Left Parenthesis, 4th Sentence, 3rd Paragraph
In the fourth sentence in the third paragraph on the page π has been printed as a left parenthesis. The sentence should read:

So, if you wanted to calculate the square root of π you could access the class method sqrt() and the class variable PI that are defined in the Math class as follows:
3/21/05

204Error in Text
On page 204, 4th para, 2nd last sentence, same error.
2-23-11

210Pi represented as Left Parenthesis
In the the second sentence in first paragraph below the code π has been printed as a left parenthesis. The sentence should read:

The method uses the class variable PI and the instance variable radius in the volume calculation – this is the expression
4.0/3.0*PI*radius*radius*radius ( corresponding to (4/3)πr3 ) in the return statement.
3/21/05

304Error in Text
first paragraph, fifth line down:
Because you have defined a constructor, no default destructor will be defined...

should be:
Because you have defined a constructor, no default constructor will be defined...
8/28/06

306No Case in Switch
The definition of the toString() method in the middle of the page will not compile as written because there is no default case in the switch. The method should be defined as:

public String toString() {
switch(this) {
case small:
return "S";
case medium:
return "M";
case large:
return "L";
case extra_large:
return "XL";
default:
return "XXL";
}
}
3/27/05

549Figure 13-1 - Leftmost and Rigtmost Boxes
The leftmost and rightmost boxes of the lower group of three In Figure 13-1 are incorrect.

The leftmost box should contain:
LinkedList<String>
that defines an object
to store String object
references in a linked list.

The rightmost box of the three should contain:

LinkedList<PolyLine>
that defines an object
to store PolyLine object
references in a linked list.
4/21/05

613Typo in Figure 14-6
The Block "Enum" is repeated twice in the diagram.
11/20/08

614Error in bottom block of diagram in Figure 14-7
In Figure 14-7 "SortedList" in the block at the bottom of the diagram should be "SortedSet".
1/22/05

660Error in Code
At the bottom of the page the code line:

java.util.Arrays(people, new Person("John", "Doe");

should be:

java.util.Arrays.fill(people, new Person("John", "Doe"));
4/21

661Error in Shaded Code
In the shaded code towards the top of the page the lines:

java.util.Arrays(people, 0, 50, new Person("Jane", "Doe");
java.util.Arrays(people, 0, 100, new Person("John", "Doe");

should be:

java.util.Arrays.fill(people, 0, 50, new Person("Jane", "Doe"));
java.util.Arrays.fill(people, 0, 100, new Person("John", "Doe"));
4/21/05

729Figure 16-4
In Figure 16-4 the text in the lower of the three boxes to the right in the figure labeled "thread3" should be:

"created as a user thread"
3/27/05

762Typo in Second Sentence, Last Paragraph
There is a typo in the second sentence in the last paragraph on the page. The sentence should read:

"The static synchronizedList() method is a parameterized method in the Collections class that accepts an argument of type List<T> and returns a reference of type List<T> to a collection class object that is synchronized."
3/27/05

772Line of Missing Code, 2nd to Last Code Fragment
There is a line of code missing from the try block in the second to last code fragment on the page, which should read:

try {
UIManager.setLookAndFeel("com.sun.java.plaf.motif.MotifLookAndFeel");
javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
} catch(Exception e) {
System.err.println("Look and feel not set.");
}

There should also be a sentence following this code fragment that reads:

"Calling the static updateComponentTreeUI() method in the SwingUtilities class causes the frame window to be updated with the look-and-feel that is currently set."
3/27/05

772Line of Missing Code, Last Code Fragment
There is a line of code missing from the try block in the last code fragment on the page, which should read:
try
{
  UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeel() );
  javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
}
catch(Exception e)
{
  System.err.println("Look and feel not set.");
}
3/27/05

772Error in Shaded Code Block
The last shaded block of code on the page should be:
try
{
  UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
  javax.swing.SwingUtilities.updateComponentTreeUI(aWindow);
}
catch(Exception e)
{
  System.err.println("Look and feel not set.");
}
4/21/05

772Error in Code
In the sentence following the last shaded block of code on the page:

"getSystemLookAndFeel()"

should be

"getSystemLookAndFeelClassName()".
4/21/05

878Error in Code
code example on page 878 is missing an import statement:

import javax.swing.SwingUtilities;
05/26/2008

1402Last sentence before "Hexadecimal Numbers" section
The last sentence preceding the section title "Hexadecimal Numbers" should read:
In general, if you have n bits available, you can represent 2n positive integers with values from 0 to 2n-1.
1/22/05