
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.”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()
}
for (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]()
Remove 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
private var balance = initialBalance
add
def currentBalance = balance
max to maxLength{ in public interface
ShortLogger extends Logger {$ from
!#$%&*+-/:<=>?@\^|~f is is not a function” to “If
f is not a function”Iterable to SeqChange “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.”
XML.save(writer, root, "UTF-8", false, null) to
XML.write(writer, root, "UTF-8", false, null)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
// You can write the second parameter as find:
Person => Person
to
// You can write the second parameter as find:
Student => 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”target”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] {
* or /” to
“because there is no *” def ones: Parser[Any] = "1" ~ rep("1")
to
def ones: Parser[Any] = "1" ~ ones
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.”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
textField.setEnabled(false)
Thanks to Ari Meyer, Jason Blochowiak, Stephyn Butcher, Rob Dickens, Stephen Eldridge, Ersin Er, Dominik Gruntz, Matt Hurne, Edgard Kassab, Jessica Kerr, William King, Alina Kirsanova, Konstantin Milyutin, Vladimir Nikolaev, Marcello Presulli, Alex Ignácio da Silva, Brad Smith, Daniel Sobral, Romain Tribes, Philip Watson, Tyler Weir, Akim Zadeh, 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!