• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 115
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 115
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey thanks for the explanation
Problem solved.
I feel so dumb to ask such silly problems...Thanks a lot Greg Charles!!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic