The errata list is a list of errors and their corrections that were found after the product was released.
The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.
Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update
Version |
Location |
Description |
Submitted by |
Date submitted |
PDF |
Page Table3.2
final in Modifier column Field in the Used on column |
The description for Field reads as follows:
Field The field cannot have its value changed. static final fields are compile-time constants.
The sentence "static final fields are compile-time constants" is not completely correct.
A static final field may have been initialized in the class initializer block(static block) in which
case it is a runtime constant. only if the static final field is initialized at declaration then it
is a compile-time constant
e.g.
public class SomeClass {
public static final int x;
public static final int y = 7;
static {
x = 5; // in this case x is not a compile-time constant
}
public void someMethod() {
int z = 5;
switch (z) {
case x: // would fail to compile, since x is not a compile-time constant
case y: // would compile as y is a compile-time constant
}
}
}
|
Pravin Jain |
Jul 05, 2023 |
PDF |
Page 105
last paragraph before summary |
Currently the second sentence of the paragraph reads as follows:
You still must define a class matching the name of the file and a main() method, but then you can execute the program with:
java MyClass.java
I have tested on Linux Jdk version 17, and found that name of the class may not match the file name still it works. It expects the first type definition(class, interface, enum or record) to contain the main method, and executes that main. e.g.
In a file named Hello.java, if I define class as follows:
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
and then give the command
java Hello.java
it still executes the main found in HelloWorld class.
|
Pravin Jain |
Jul 03, 2023 |
Printed |
Page 235
Top of the page, Last bullet |
Sentence reads, "...reset objects to a legal state before throwing" should conclude the statement by adding " an exception". Final version would be, "...reset objects to a legal state before throwing an exception".
|
Dan Wilkin |
Aug 18, 2023 |