File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To prove that methods can be overriden but attributes cannot be.

 
Khuma Chhakchhuak
Ranch Hand
Posts: 37
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have run the following code (JunkFirst.java)in eclipse to prove that only methods can be overriden. It is throwing runtime exception "stackoverflow". How do I correct the error?


 
dennis deems
Ranch Hand
Posts: 808
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an infinite recursion. In your definition of the class Child, you have an instantiation of that class. That means that any time you try to instantiate a new Child, that instance will instantiate a new Child, and then that instance will instantiate a new Child, and so and so on until the stack runs out of space.
 
Khuma Chhakchhuak
Ranch Hand
Posts: 37
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dennis.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic