• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling a method that throws Exception?  RSS feed

 
ajay smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a file greenGrow.txt, and every three lines of the file has a last name, first name, and yard size. Every time a Customer object is created, I need to read the file 3 lines and assign the object a last name, first name, and yard size.

Snippet of my code:


My issue is that I cannot call readFile() from the constructor, and I'm assuming that's because I throw Exception on readFile(). Is this a simple fix, or am I looking at it the wrong way?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your constructor needs to either catch and handle the Exception or throw it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!