Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes I/O and Streams and the fly likes error in code please help!!!!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "error in code please help!!!!!!!" Watch "error in code please help!!!!!!!" New topic
Author

error in code please help!!!!!!!

sumedha rao
Ranch Hand

Joined: Nov 26, 2010
Posts: 115

I was practising on how to use static methods in java but had some problem in compling the program.

In the program below i want the user to enter(command line arg) the current balance and the ammount he wants to withdraw.

I get the following errors:
line 8 and 11:
unreported exception java.io.IOException;must be caught or declared to be thrown



Any help would be of great help.
Thanks

scjp1.6,scwcd1.5!!!
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2850
    
  11

Welcome to JavaRanch! In the future try to UseCodeTags and UseAMeaningfulSubjectLine. I've added code tags for you to make things easier.

Now, how much do you know about exceptions in Java. There are checked exceptions and unchecked exceptions. IOException is a checked exception, which means if you call something that can throw an IOException, then you need to either put that call in a try block, and follow with a catch block that catches IOException or one of its superclasses, or you need to declare your method to throw IOException or one of its superclasses. If you look at the Javadocs for BufferedReader, you'll find that the readLine() method can throw IOException, so that's your problem. Let us know if that explanation doesn't make sense, and we'll a back up a step or two.
sumedha rao
Ranch Hand

Joined: Nov 26, 2010
Posts: 115

Hey thanks for the explanation
Problem solved.
I feel so dumb to ask such silly problems...Thanks a lot Greg Charles!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in code please help!!!!!!!