• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stack overflow error on creating new instance

 
Gus Smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

Having major problems trying to create a new instance of the class LibraryCard within my other class Library's method. I keep getting stack overflow errors, which from what I know is caused by recursion, but have no idea how to fix this.

Ideally it should create a new library card with a limit of 5 and a cardID of the number in the borrowers variable when the issueCard method is called, but as it stands it just loops forever and doesn't return anything. Any help or nudges in the right direction would be appreciated.
 
Rob Spoor
Sheriff
Pie
Posts: 20494
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gus Smith wrote:

Change the return from issueCard() - which is a call to the same method - to issueCard - the variable you created two lines higher.
 
Gus Smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that fixed it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic