Head First Java vs. Think in Java

S

Stefan Ram

Clarence Blumstein said:
If you must choose one ,which one do you like it? Why?

Recently someone claimed that "Thinking in Java 3",
contained this sentence:

|If you're defining an anonymous inner class and want to use an
|object that's defined outside the anonymous inner class, the
|compiler requires that the argument reference be final, like
|the argument to dest().

Here, Eckel writes:

»object that's defined«.

Objects, however, are not "defined", they are /created/ at
run-time. Names of reference variables are being /declared/
in the source text, not "defined".

http://java.sun.com/docs/books/jls/third_edition/html/statements.html#5920

Then, he continues to write

»argument reference be final«.

This might intend to say that a reference parameter was
declared with "final". "final" is not an attribute of a,
/reference/, but of a variable.

However, this is not about /arguments/ (the reference
arguments do not have to be declared "final" here), but
about /parameters/. The distinction between these two
Java terms seems to be unknown to Eckel.

parameter:

http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.8.7

arguments:

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.12

He also writes:

»the compiler requires«.

It might be the case that the compiler of Mr. Eckel indeed
requires this, but he should teach a language instead of an
implementation, so it might be preferable to write
"the language specification requires«.

Also, anonymous inner classes are not being /defined/ in
Java, as Eckel writes at the beginning of the quotation, but
they are being /declared/.

Moreover, "anonymous" is an unnecessary restriction, because
the assertion is valid for /all/ inner classes. Someone
learning by this sentence thus needs to learn anew at another
time that this is also valid for non-anonymous inner classes,
or he might believe erroneously for an indetermined amount of
time, that it is only valid for anonymous inner classes.

Is there a way to improve the sentence? One attempt by me:

A parameter to be used within an inner class of its method
needs to be declared »final«.

Even the Java Language Specification itself is easier to
read than Eckel (and of course, much more correct):

Any local variable, formal method parameter or exception
handler parameter used but not declared in an inner class
must be declared final.

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3

All the reported faults have been found by me within a single
sentence chosen at random (I did not read the book, but
discovered the sentence in another posting, claiming to quote
this sentence from "Thinking in Java".) If one extrapolates this
error quotient to the whole TIJ, it gives a horrid impression.

Some books might sell chiefly because the buyer wants to
express agreement with their title. When one is learning a
foreign language one does not want to think everything in
English first and then painfully translate it word-by-word.
So one might choose "Thinking in Java" instead of a
garden-variety "Introduction to Java", because one longs for
the promise given by its title, not suspecting that the author
Eckel himself might be far from "thinking in Java".
 
R

RedGrittyBrick

If you must choose one ,which one do you like it? Why?

Effective Java ;-)

Because you can learn Java from the Sun/Oracle website tutorials. And
because it's the only one I still find useful of the many Java books I
have purchased.
 
A

Abu Yahya

Clarence said:
If you must choose one ,which one do you like it? Why?

Whatever do you, don't go for Head First Java, unless you are only a
hobbyist and are ready to throw the book out of sight after you read it.
It's full of slangy terms that barely help you learn Java and make sure
you professor laughs at you in your viva. Go for Core Java by Cay
Horstmann - it's among the most comprehensive books.
 
M

Mike Schilling

Stefan said:
Even the Java Language Specification itself is easier to
read than Eckel (and of course, much more correct):

Any local variable, formal method parameter or exception
handler parameter used but not declared in an inner class
must be declared final.

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.3

It's worth pointing out that this only applies to local and anonymous
classes, since for other inner classes there's no way that a local variable,
formal method parameter or exception handler parameter would even be visible
to them.
 
E

Eric Sosman

It's worth pointing out that this only applies to local and anonymous
classes, since for other inner classes there's no way that a local variable,
formal method parameter or exception handler parameter would even be visible
to them.

And the way they're "used" while not visible is ...?
 
M

markspace

Clarence said:
If you must choose one ,which one do you like it? Why?


Neither.

I browsed through Head First Java at the bookstore when I was looking
for Java books, and I didn't like it. I could tell just by briefly
reading through it that it covered very little and wouldn't teach me
very much.

I also have a poor opinion of Bruce Eckel's "Thinking in..." books.
Just not enough thinking went into the design and writing of those books
to be truly purchase worthy.

There may be better alternatives, but I've purchased O'Reily's "Learning
Java", 3rd ed., and used it for some time now. It's got good
explanations for the novice, as well as enough detail to last a long
time as a reference book. I still use it as a reference on certain
subjects, and I think I've had it five years now.

Also, don't overlook on-line sources. Sun's (now Oracle's) online
tutorial is adequate, and free. www.JavaPassion.com is no longer free,
but their fees are pretty nominal. I'm tempted to go through one of
their more advanced classes, just to see how it works out. Lastly,
local sources like a community college course are also very good values,
imo. They provide face-to-face time with other people in your field in
your local area, although they have the disadvantage of hassling with
transportation.
 
M

Mike Schilling

Eric said:
And the way they're "used" while not visible is ...?

Exactly. And while it's possible to conclude from that fact that the cited
paragraph only applies to local and anonymous classes, it clarifies things
to make the point explicitly.
 
S

Stefan Ram

Mike Schilling said:
It's worth pointing out that this only applies to local and anonymous
classes,

class Main
{ public static void main( final java.lang.String[] args )
{ class Local
{ class Inner
{ Inner(){ java.lang.System.out.println( args ); }}}}}

JLS: »A local class is a nested class (§8) that is not a
member of any class and that has a name.« ¯¯¯

»Inner« is a member of »Local«, so »Inner« is not a local
class nor an anonymous class, yet the above applies.
 
C

Clarence Blumstein

Effective Java ;-)

Because you can learn Java from the Sun/Oracle website tutorials. And
because it's the only one I still find useful of the many Java books I
have purchased.

Does this book have official ebook? if not, how do I pay money if I
but it on their website?
 
T

Thufir

Whatever do you, don't go for Head First Java, unless you are only a
hobbyist and are ready to throw the book out of sight after you read it.
It's full of slangy terms that barely help you learn Java and make sure
you professor laughs at you in your viva. Go for Core Java by Cay
Horstmann - it's among the most comprehensive books.


Contrast:

"Welcome to the Core Java Web Page!

Core Java by Cay S. Horstmann and Gary Cornell is a book in the Java
series of Sun Microsystems Press , published by Prentice-Hall . The book
is aimed at experienced programmers who want to learn how to write useful
Java applications and applets. No hype, no toy code, no language
lawyering, just solid facts and in-depth research to help you write real
programs."


with:

Head first:

....

"The latest research in cognitive science, neurobiology, and educational
psychology shows that learning at the deeper levels takes a lot more than
text on a page. Actively combining words and pictures not only helps in
understanding the subject, but in remembering it. According to some
studies, an engaging, entertaining, image-rich, conversational approach
actually teaches the subject better. Head First Java puts these theories
into practice with a vengeance."



Apples and oranges. One is aimed at *experienced* programmers...





-Thufir
 
R

RedGrittyBrick

Please don't quote signatures.
Does this book have official ebook? if not, how do I pay money if I
but it on their website?

Sun's Java tutorial is available free at
http://java.sun.com/docs/books/tutorial/

You can buy the "Effective Java" book at
http://www.amazon.com/Effective-Java-Joshua-Bloch/dp/0201310058
(there will be a local equivalent for your country or region)

This book is available in paid-for e-book form at Safari.
http://my.safaribooksonline.com/9780137150021

Previews of parts of this book are available online at
http://java.sun.com/docs/books/effective/

It is also in Google books
http://books.google.com/books?q=effective+java&btnG=Search+Books

I strongly recommend you purchase the book in physical form. Firstly
because it is an exceptionally good book. Secondly because it has long
term value, thirdly because you will want to encourage the author to
write further editions as Java evolves.
 
M

Mike Schilling

Stefan said:
Mike Schilling said:
It's worth pointing out that this only applies to local and anonymous
classes,

class Main
{ public static void main( final java.lang.String[] args )
{ class Local
{ class Inner
{ Inner(){ java.lang.System.out.println( args ); }}}}}

JLS: »A local class is a nested class (§8) that is not a
member of any class and that has a name.« ¯¯¯

»Inner« is a member of »Local«, so »Inner« is not a local
class nor an anonymous class, yet the above applies.

Ah, so it does. I was trying to come up with this situation, but couldn't
quite picture it. Thanks.
 
A

Arne Vajhøj

Contrast:

"Welcome to the Core Java Web Page!

Core Java by Cay S. Horstmann and Gary Cornell is a book in the Java
series of Sun Microsystems Press , published by Prentice-Hall . The book
is aimed at experienced programmers who want to learn how to write useful
Java applications and applets. No hype, no toy code, no language
lawyering, just solid facts and in-depth research to help you write real
programs."

with:

Head first:

...

"The latest research in cognitive science, neurobiology, and educational
psychology shows that learning at the deeper levels takes a lot more than
text on a page. Actively combining words and pictures not only helps in
understanding the subject, but in remembering it. According to some
studies, an engaging, entertaining, image-rich, conversational approach
actually teaches the subject better. Head First Java puts these theories
into practice with a vengeance."

Apples and oranges. One is aimed at *experienced* programmers...

And that is important.

There is a big difference between books for experienced and books
for beginners.

The first need to focus on accuracy and completeness.

The second most focus on the communication.

And in many ways the second is the most difficult. It is easy
to show a lot of complex stuff about a specific framework to
a bunch of experienced programmers. It is bloody hard to
explain both programming and a specific programming language
to absolute beginners.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top