aspose file tools*
The moose likes Beginning Java and the fly likes Thinking in Java !! It really makes me think Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thinking in Java !! It really makes me think" Watch "Thinking in Java !! It really makes me think" New topic
Author

Thinking in Java !! It really makes me think

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
"As usual, constructors are different from other kinds of methods. This is
also true when polymorphism is involved. Even though constructors are
not polymorphic (they�re actually static methods, but the static declaration is implicit)it�s important to understand the way constructors
work in complex hierarchies and with polymorphism."

3rd Edition,Chapter 7(Polymorphism),page 315

Now, i just want to know what does the author mean by calling constructors,static methods,because we don't have static constructors in Java?Thanks a lot..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
I think what he means is that they are something which is called from the class rather than an instance, but I suspect calling constructors "static" and calling them "methods" are both inaccurate. I was told off once on this site for calling constructors "static" because of that quote.

Anybody else?
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks for the reply,but still i m in doubt.I have read the review of Thinking in Java,written by kathie Sierra herself.I think of this book very highly,and any comment in this book should'nt be taken lightly...
Leroy J Brown
Ranch Hand

Joined: Dec 02, 2007
Posts: 71
I think this is more a problem for Wittgenstein than for programmers. I feel fairly certain that what the author means is that constructors (things very much like methods though maybe technically not) belong to classes and not objects (very much like static methods do though maybe they're technically not static). The problem here is just in terminology which from a learning perspective is pretty useless. Technically in this case means whatever the JLS writers wanted to call it. They name somethings well and somethings less well but you'll always run into conceptual problems.

Java's answer to static constructors is the static initializer. It's called called a static initializer because its used to initialize static variables when a class is loaded. That's not very much like what the author means by saying that the constructor is static but you can see why he used that word. He meant it to be conceptually helpful and in this case it was not.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I have a lot of respect for Eckel and his Thinking in Java books, but I think he's occasionally a bit casual with his terms. (Another example is his use of "inner classes," which is not consistent with the Java Language Specification.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
[Edited] Deleted. The response was based on a misunderstanding.
[ August 24, 2008: Message edited by: Adeel Ansari ]
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Originally posted by Adeel Ansari:


If you are damn sure, just because its written by Kathy, so let me make it clear to you, its not. You might be confusing Head First Java with Thinking in Java.

Cheers.


Originally posted by Max white
I have read the review of Thinking in Java,written by kathie Sierra herself.

Max is saying that the review is written by Kathy not the book.

I also have respect for the books by Bruce Eckel and as marc says, Eckel is a bit casual with his terms and one more reason I think is his very strong C++ background


SCJP, SCWCD.
|Asking Good Questions|
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Amit Ghorpade:
Max is saying that the review is written by Kathy not the book.


Oops!! my mistake.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
Originally posted by Adeel Ansari:


Oops!! my mistake.
Think nothing of it; we all make mistakes like that.
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks to all but i feel you all missed one important point,



Now is it even possible for someone like Bruce Eckel to write this casually?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Max White:
... Now is it even possible for someone like Bruce Eckel to write this casually?

I think Eckel's style is to illustrate concepts in different ways, and his emphasis is more on getting you to understand how things work rather than using ultra-precise terminology that's always in accordance with the Java Language Specification.

In the 3rd edition of TIJ, he introduces the concept by saying...
You can imagine creating a method called initialize() for every class you write. The name is a hint that it should be called before using the object.

He then expands on this concept of an initializer method by saying...
In Java, the class designer can guarantee initialization of every object by providing a special method called a constructor.

Maybe the key is what the word "special" entails, but I'm not sure he really defines that.
[ August 25, 2008: Message edited by: marc weber ]
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks for the explanation,marc.I m getting to understand things.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thinking in Java !! It really makes me think