
On the bottom of the copyright page (facing the first page of the table of contents), look for a line such as
First printing, March 2012
In the errata below, we indicate the printing in which the error has been fixed inside square brackets such as [4].
For example, suppose you have the fourth printing. Then you can ignore all reports that are prefixed with [2], [3] or [4]. But you would want to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.
else -1.” to “Then it gets confused about the else keyword.”r = r * x” to “to separate r = r * n”val url = new URL("http://horstmann.com/fred-tiny.gif")
try {
process(url)
} catch {
case _: MalformedURLException => println("Bad URL: " + url)
case ex: IOException => ex.printStackTrace()
}
var in to val infor (elem <- a if a % 2 == 0) yield 2 * elem
to
for (elem <- a if elem % 2 == 0) yield 2 * elem
var first = false to var first = trueval bSorted = b.sorted(_ < _) // b is unchanged; bSorted is ArrayBuffer(1, 2, 7, 9)
to
val bSorted = b.sorted // b is unchanged; bSorted is ArrayBuffer(1, 2, 7, 9)
Change “You pass the comparison function as a parameter—see Chapter 12 for the function syntax.” to
You can also supply a comparison function, but then you use the sortWith method:
val bDescending = b.sortWith(_ > _) // ArrayBuffer(9, 7, 2, 1)
See Chapter 12 for the function syntax.
If you want to start out with a blank map, you have to pick a map implementation and supply type parameters:
val scores = new scala.collection.mutable.HashMap[String, Int]
to
If you want to start out with a blank map, you have to supply type parameters:
val scores = scala.collection.mutable.Map[String, Int]()
java.reflect.BeanProperty to java.beans.BeanPropertyRemove the / from “If that gets too tedious, use a statement /”
Change “next = previous × a + b mod 2n” to “next = (previous × a + b) mod 2n”. Change “ and n = 32.” to “n = 32, and the inital value of previous is seed.”
var salary: 0.0 to var salary = 0.0final field is immutable, similar to val in Scala.public class Person to class Personpublic class Employee extends Person to class Employee extends Personclass Bug extends {
override val range = 3
to
class Ant extends {
override val range = 2
Anyval to AnyValprivate var balance = initialBalance
add
def currentBalance = balance
max to maxLength{ in public interface ShortLogger extends Logger {JContainer to JButton$ from !#$%&*+-/:<=>?@\^|~private int to private val (2x)f is is not a function” to “If f is not a function”largestAt(fun: (Int) => Int, inputs: Seq[Int]) to largestAt(x => 10 * x - x * x, 1 to 10)Iterable to Seqser method” to “with the seq method”Change “The tupled method of the Function2 class” to “The tupled method of the Function object”
head: B to head: E
Change unapply(result) to unapply(lst)
alls? thr to [Ff]alls? thrProduct to Articlesqrt(Double) to sqrt(x)Comparable[Student] to Comparator[Student]Comparable to Comparator (2x)Change “Section 16.2 shows the complete hierarchy.” to “Figure 16-1 shows the complete hierarchy.”
alt="San José State University Logo" to alt="San José State University Logo"XML.save(writer, root, "UTF-8", false, null) to XML.write(writer, root, "UTF-8", false, null)Pair[java.io.File] to Pair[java.net.URL] and “but File does not implement Comparable[File]” to “but URL does not implement Comparable[URL].”It requires that there is an “implicit value” of type T[M].
to
It requires that there is an “implicit value” of type M[T].
T <: Upper >: Lower
to
T >: Lower <: Upper
<%<Pair[File], even though File is not ordered.” to “You can form a Pair[URL], even though URL is not ordered.”// You can write the second parameter as find: Person => Person
to
// You can write the second parameter as find: Student => Person
class Person extends Friend[Person]to
class Person extends Friend[Person] { ... }foldLeft[B](z: B)(op: (A, B) => B): B to foldLeft[B](z: B)(op: (B, A) => B): Bvoid makeFriends(Pair<? extends Person> people)
to
void makeFriends(List<? extends Person> people)
v” to “Given any reference v”Object instance as parameter” to ““a method that takes an object instance as parameter”Network instance”Change “where T1, T1, T1, and so on are types” to “where T1, T2, T3, and so on are types”
abstract trait to trait (2x)def read(in: In) to def read(in: In): Contentstrait ActionListener {
to
trait ActionListener extends Listener {
object ButtonModule extends ListenerSupport
{
to
object ButtonModule extends ListenerSupport {
class Buffer[E] extends Iterable[E]
to
class Buffer[E] extends Iterable[E] {
((3~List())~Some((-~((4~List((*~5)))~None))))
the expression (3~List()) should be in bold.
* or /” to “because there is no *” def ones: Parser[Any] = "1" ~ rep("1")
to
def ones: Parser[Any] = "1" ~ ones
def ones: Parser[Any] = ones ~ "1" | "1"
for the first code display on the page.
case class Compute(input: Seq[Int], result: OutputChannel[Int])
class Computer extends Actor {
while (true) {
receive {
case Compute(input, out) => { val answer = ...; out ! answer }
}
}
}
to
case class Compute(input: Seq[Int], result: OutputChannel[Int])
class Computer extends Actor {
public void act() {
while (true) {
receive {
case Compute(input, out) => { val answer = ...; out ! answer }
}
}
}
}
val c = new Channel to val channel = new Channel (2x). Change case !(c, x) => to case !(channel, x) => ?! operator” to “by using the !? operator”react never returns a value” to “ “The partial function associated with the first react never returns a value””javax.imageio.IOImage.read to javax.imageio.ImageIO.readval for a given data type.” to “There can only be one implicit value for a given data type.”Ordering[Int] in the Predef scope” to “an implicit value of type Ordering[Int] in the Ordering companion object”T <%< U =:=, <:<, and <%<” to “ =:= and <:<”<::< to <:<5! is 120. You will need an enrichment class and an implicit conversion.”Obtain to Read ink: (String => String) => {
"Exit"
}
to
k: (String => String) => "Exit"
shift {
k: (Unit => Unit) => { // A and B are Unit
"Exit" // C is String
} // Shift hole is Unit
}
to
shift {
k: (Unit => Unit) => // A and B are Unit
"Exit" // C is String
} // Shift hole is Unit
process(response1, response2) //textField.setEnabled(false)
Thanks to Abdussalam Abdurrahman, Kamal Advani, Marko Asplund, Jason Blochowiak, Stephyn Butcher, Donna Converse, Charles David Crawford III, Sanjay Dasgupta, Rob Dickens, Stephen Eldridge, Ersin Er, Carey Evans, Andreas Flueckiger, Kelly Gerber, Dominik Gruntz, Susan Hoover, Matt Hurne, Edgard Kassab, Jessica Kerr, William King, Alina Kirsanova, Andrey Kudryavtsev, Anh Le, Javier Lopez, Alexander Mentis, Ari Meyer, Konstantin Milyutin, Vladimir Nikolaev, Thiago Presa, Marcello Presulli, Mike Shields, Alex Ignácio da Silva, Brad Smith, Daniel Sobral, Deepak Sulakhe, Ryuu Suou, Allan Todd, Romain Tribes, Philip Watson, Stephan Warren, Tyler Weir, Harald Zauner, Akim Zadeh, Vincent Zheng, Kefu Zhou, Gerhard Zorn, and (your name might go here) for their bug reports and suggestions!
Please use this form to report any bugs that you find. Please check the list of known bugs first before you report a bug. Unfortunately, I do not have the time to respond personally to every report, but I do read them all and will post updates to this page. Thank you!