• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thinking in Java !! It really makes me think

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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..
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Edited] Deleted. The response was based on a misunderstanding.
[ August 24, 2008: Message edited by: Adeel Ansari ]
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Amit Ghorpade:
Max is saying that the review is written by Kathy not the book.



Oops!! my mistake.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Adeel Ansari:


Oops!! my mistake.

Think nothing of it; we all make mistakes like that.
 
Max White
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the explanation,marc.I m getting to understand things.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic