aspose file tools*
The moose likes Beginning Java and the fly likes Stack overflow error on creating new instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Stack overflow error on creating new instance" Watch "Stack overflow error on creating new instance" New topic
Author

Stack overflow error on creating new instance

Gus Smith
Greenhorn

Joined: Nov 05, 2011
Posts: 8
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

Joined: Oct 27, 2005
Posts: 19693
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gus Smith
Greenhorn

Joined: Nov 05, 2011
Posts: 8
Thanks, that fixed it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Stack overflow error on creating new instance