Java by Dissection Second Edition is now available.

Java by Dissection

by Ira Pohl and Charlie McDowell   

Addison-Wesley ISBN 0-201-61248-8

Enlisting the best-selling dissection method, this title teaches programming techniques and presents the Java language using a sound and structured method. Working code is dissected with explanations to the student on each newly encountered programming element and idiom found in the code. The presentation assumes no programming background; both CS1 students and experienced programmers unfamiliar with Java will find a carefully structured presentation of the Java language and its key programming concepts.

Features

Ira has also developed a general course outline for an introductory course in programming using this text.

Charlie McDowell has notes with slides for teaching from the Java by Dissection book.

The first three chapters of Java by Dissection are available for free in eMatter form as Chapter 1, Chapter 2, Chapter 3. You can buy this book online through Barnes and Noble.

The Java code examples in the book are available in several forms. The code is arranged in directories corresponding to the chapters of the book. To get to the unpacked version for any system, or to get individual program files, you can use the FTP directory (www.cse.ucsc.edu/~pohl/JBD/). Files are also available in zip form for Windows users and compressed tar form for UNIX users.

More information and the source code for the tio package is also available.


Errata

Caveats: Some standard libraries may have been modified since this book was written and the function prototypes may differ from what is available on your compiler. Check your compiler vendor for the correct prototypes.

Notations: p425 means page 425  
                            +8 means 8 lines from top 
                             -7 means 7 lines from bottom

If you encounter errata in this book not listed here, please contact Ira Pohl via email at pohl@cse.ucsc.edu with your errata. You will be cited in the correction if you are the first to report it.


p4 (June Yoshiko Sison) Just after the table, change "To execute step1, place the first number, 77, in the box pennies" to"...in the box price."

(Corrected in eBook) (Correction submitted to AWL)


p 6 (Brian Chavez) line 6 change (0:100):"); to (0 to 100):");

(posted October 2001)


p11 (Charlie McDowell) We refer to www.JavaByDissection.xyz as the website at which you can obtain the Draw applet. There is no such website and the name of the applet should be MiniCalcApplet. The MiniCalcApplet in the book is consistent with version 1.2 of the JDK and it can be found in the FTP directory for the book in chapter 8 at

http://www.cse.ucsc.edu/~pohl/JBD/chap8/MiniCalcApplet.html

An additional version, for those of you who have only JDK 1.1.x, is available at http://www.cse.ucsc.edu/~charlie/java/jbd/MiniCalcApplet.html.

(Corrected in eBook) (Correction submitted to AWL)


p34 (Steffen Vissing Andersen) line 2 in the table: 99 ... 112 should be 99 ... 122

(Correction submitted to AW July 2001)


p35 (James Sears) line -10 The output is confusing. It would be better to replace the colon with the word "to" so that

System.out.println("type price (0:100):");

should be

System.out.println("type price (0 to 100):");


p44 (Charlie McDowell) line -1, the -b + needs to be in front of the quare root expression as part of the numerator.

(Corrected in eBook)

p51 (Charlie McDowell) exercise 15, inreadChar() should be in.readChar()

(Correction submitted to AWL) (Corrected in eBook)


p56 ( Linda Beattie) lines 3-4 Tthe sentence "Declaration statements start with a type and are followed by a comma separated by a list of variables" should instead read "Declaration statements start with a type and are followed by one or more variables, separated by commas."

(Correction submitted to AWL)


p82 - 83 (Vera Ta) Every occurence of println(...) that isn't System.out.println() needs to be changed to be System.out.println(). This occurs in the final else of the if-else example on page 82, in every case of the switch on page 82, and in the default case of the switch on page 83.

(Corrected in eBook) (Correction submitted to AWL)


p87 line 4, (Melissa Chan) "executed" is misspelled as exeucted in the comment.

(Corrected in eBook) (Correction submitted to AWL)


p89 exercise 6, (Charlie McDowell) it should be a^2 + b^2 = c^2 not multiplication

(Correction submitted to AWL) (Corrected in eBook)

p91 (Charlie McDowell) (for next edition) change exer 22 to say

"Run the computation for 20 terms..." instead of 100. It has converged after 20 and the next 80 just confuse the issue by scrolling the important stuff off of the screen.

(Correction submitted to AWL) (Corrected in eBook)

p 98 (Brian Chavez) line -5 change i < k to i < howManyTimes

(posted October 2001)

p 106 (Brian Chavez) line -18 (in second bulleted item) Change

sum = smallest = biggest = item;

to

smallest = biggest = item;

(posted October 2001)



p108 (Richard Johnson) lines 6-8 are missing the line breaks shown in the output. It should read:

System.out.println("\nCount: " + k
+ "\nMaximum: " + biggest
+ "\nMinimum: " + smallest);

(Corrected in eBook) (Correction submitted to AWL)


p135 (Charlie McDowell) exercise 1 remove the word "following" so that it reads "Rewrite the class Message from page 96 so that

(Correction submitted to AWL) (Corrected in eBook)

p137 (Charlie McDowell) exercise 17(just formatting) The letters a-g should be instead numbers 1-7 because the text refers to step1.


p152 (Steffen Vissing Andersenl) line 21 change //initial max value to //initial min value.

(Correction submitted to AW July 2001)


p160 (Steffen Vissing Andersenl) line 22 needsto init the index to 2 instead of 0, so that 0 and 1 won't be listed as primes. Change

for ( i = 0; i < 100; i++)

to

sieve[0] = sieve[1] = false;

for ( i = 2; i < 100; i++)

(Correction submitted to AW July 2001)


p165 (Steffen Vissing Andersenl) line -11 needs semicolon at end of int[] ragged = ...};

(Correction submitted to AW July 2001)


p187 (Steffen Vissing Andersen) In math equation swap L and R so it reads

(L i,k . R k, j)

(Correction submitted to AW July 2001)


p186 (Charlie McDowell) (end of exercise 14) change eval() to evalPoly().

(Correction submitted to AWL) (Corrected in eBook)

p190 (Charlie McDowell) 1st line second paragraph "on page 31" should be "on page 23"

(Correction submitted to AWL) (Corrected in eBook)


p194 (Charlie McDowell) The last paragraph return values are incorrect. The changes are shown in boldface. The paragraph should read:

These calls to method compareTo() will return a number less than 0 if str1 is lexicographically before the parameter. Essentially that means alphabetical order, but it also specifies an ordering for nonalphabetic characters. The calls will return a number greater than 0 if str1 is lexicographically after the parameter, and they will return 0 if the strings are equal.

The actual value is the difference of the first characters that didn't match. So in s1.compareTo(s2), if they differ at index diff then the return value is s1.charAt(diff) - s2.charAt(diff)

(Corrected in eBook) (Correction submitted to AWL)


p197 (Charlie McDowell) the third line in the table should read: StringBuffer(int capacity) ... not String(int capacitiy)

(Corrected in eBook) (Correction submitted to AWL)


p210 (Charlie McDowell) line -16,

pennies = (int)((diff-dollars) * 100);

should be

pennies =(int)Math.round((diff-dollars) * 100);

(Correction submitted to AWL) (Corrected in eBook)

p219 (Richard Johnson) line 2 comment has MODOULOUS misspelled. It should be MODULUS

(Corrected in eBook) (Correction submitted to AWL)


p220 (Charlie McDowell) (technically correct but ugly) in the class Pips, the line

return new Integer(p).toString();

should be

return String.valueOf(p);

(Correction submitted to AWL) (Corrected in eBook)


p221 (Dr. Richard Johnson) In method toString() change

t = t + "\n" + deck[i];

to

t = t + deck[i] + "\n";

(Correction submitted to AWL)


p221 (Steffen Vissing Andersen) In method shuffle() change

Card t = new Card(deck[i]);

to

Card t = deck[i];

(Correction submitted to AW July 2001)


p222 (Dr. Richard Johnson) In the dissection of method toString() change

t = t + "\n" + deck[i];

to

t = t + deck[i] + "\n";

(Correction submitted to AWL)


p222 (Steffen Vissing Andersen) In method shuffle() change

Card t = new Card(deck[i]);

to

Card t = deck[i];

(Correction submitted to AW July 2001)


p223 (Lei Chen) line 4, argv should be args.


p227 (Charlie McDowell) (minor grammatical error) "from an nonstatic" should be "from a nonstatic"

(Correction submitted to AWL) (Corrected in eBook)

p228 (Charlie McDowell) exercise 9"the upper left corner" should be "the lower left corner"

(Correction submitted to AWL) (Corrected in eBook)

p230 (Dr. Richard Johnson) In the pseudocode for finding the root of a polynomial, change the third line to be

while the absolute value of (a - b) > epsilon

(Correction submitted to AWL)


p235 (Morten Ovi) line 1 subclass should be superclass

class class-name extends subclass-name {

should be

class class-name extends superclass-name {


p244 (Charlie McDowell) Common Programming Error the class SomeSub extends
SomeSuper so

class SomeSub {

becomes

class SomeSub extends SomeSuper {

(Correction submitted to AWL) (Corrected in eBook)


p261 (Charlie McDowell) In the grey box at the top, change the three occurences of StudentWorker to StudentEmployee.

(Correction submitted to AWL)


p270 (Steffen Vissing Andersenl) Sample AWT Components at top of screen shot should be Sample Swing Components

(Not sent to AW )


p 274 (Rick Johnson) The Class HelloGoodBye can use either Button or JButton.

(Correction submitted to AWL)

Page 275 ( Jonathan Stauduhar) In list item number 4 change ActionEventListener to ActionListener (two occurrences).

(Correction submitted to AWL)

p292 (John Carter) line 18 (x radius, y radius) are missing their hyphens. It should read

(x-radius, y-radius).

(Corrected in eBook) (Correction submitted to AWL)


p317 (Charlie McDowell) (1st noncode line) "As in Plot2..." should be "As in Star2..."

(Correction submitted to AWL) (Corrected in eBook)

p319 (Charlie McDowell) The class DrawTriangle is misnamed. It should be called DrawSomeLines. The comment for that class should read:

//DrawSomeLines.java - two ways to draw lines

At one time we used drawPolyline() here to draw a triangle, but we don't now. The code works, the description is just misleading.

(Correction submitted to AWL)

p339 (Craig Abbott) JText Area and JTextField are different from TextArea and TextField in that they do not generate java.awt.TextEvents. There is no simple edit that can explain how to do this witth JTextComponents. This should be addressed in any new edition. For now, the correction would be to delete the two lines inthe table beginning with TextListener in column 1.

(Correction submitted to AWL)


p344 (Charlie McDowell) Exercise 17 Remove the comment

//code to update position and velocity here

(Correction submitted to AWL) (Corrected in eBook)

p356 (Rick Johnson) The first two lines in the body of the round() method are for debugging purposes and should be deleted from the code. They are

double temp = Double.parseDouble(s);
System.out.println(temp);
(Correction submitted to AWL)

p357 (Rick Johnson) lines 3-4 The form.setMaximumDecimalDigits() should be form.setMaximumFractionDigits()

(Correction submitted to AWL)

p375 (Ira Pohl): line 7 in code (and in later dissection on the same page)

catch(NumberFormatException) {

should be

catch (NumberFormatException e) {

(Correction submitted to AWL) (Corrected in eBook)


p376 (Steffen Vissing Andersen) In first line of code in Common Programming Error box, change

while (confirm = 'N') {

to

while (confirm == 'N') {

(Correction submitted to AW July 2001)


p389 (Steffen Vissing Andersen) line -5 change

if (v = -1)

to

if (v == -1)

(Correction submitted to AW July 2001)


p485 (Charlie McDowell) line -12 if statement has statements out of order. Replace

String needs Rounding = ... }

with

   if (exp == -1)
      return round(value);
   else {
      String needsRounding = value.substring(0, exp);
      return round(needsRounding) + value.substring(exp);
   }

(Correction submitted to AWL) (Corrected in eBook)


p474 (Eric Cain) lines 18-19 comment is incorrect. Remove the two lines starting with

* @exception FileNotFound ...

(Corrected in eBook) (Correction submitted to AWL)


p498 (June Yoshiko Sison) In the index entry for applet, ??-301 should be 298-301.

(Correction submitted to AWL)

p507 (Charlie McDowell) There is an error in the index entry for stream, it includes question marks

(Correction submitted to AWL) (Corrected in eBook)