aspose file tools*
The moose likes Beginning Java and the fly likes Static code in abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static code in abstract class" Watch "Static code in abstract class" New topic
Author

Static code in abstract class

S Reddy
Ranch Hand

Joined: May 17, 2007
Posts: 45
I have read "abstract classes shouldn't contain static blocks" from Complete reference book. Is this true?

When static blocks are associated with class, why they couldn't be included in abstract classes?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

I can't think of any reason for a blanket statement like that. Don't know what this "Complete" book is, but if you have a book that makes claims like this without explaining them, I'd use it for kindling.

If the book includes an explanation and you'd like help understanding it, please share it with us!


[Jess in Action][AskingGoodQuestions]
S Reddy
Ranch Hand

Joined: May 17, 2007
Posts: 45
There is no explanation. The book is "Java 2 Complete Reference, 5th edition" by TATA - McGraw Hill. Author is: Herbert Schildt.
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
can you include the code?


Brazil - Sun Certified Java Programmer - SCJP 5
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
S Reddy
Ranch Hand

Joined: May 17, 2007
Posts: 45
There is no code given in the book. He just mentioned that abstract classes should not contain static blocks. I am just confused why java was developed like that?
Shivit Agarwal
Ranch Hand

Joined: Feb 28, 2008
Posts: 82
Well the statement is incorrect in case if he has written such. If you don't believe write a short program to prove your point.

Also can you please mentioned the Page No. in which you came across the statement.


Have the determination of mirror which never fails to reflect in spite of being broken into pieces.<br /> <br />Kiss the hands you cannot bite.<br /> <br />An Optimist is one who starts taking a bath when he accidentally falls into the water.
S Reddy
Ranch Hand

Joined: May 17, 2007
Posts: 45
Thank you all.
 
 
subject: Static code in abstract class