• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

throws ExceptionIO error  RSS feed

 
Greenhorn
Posts: 13
1
C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




I am trying to run this code but I am getting error in line "throw io.IOException;"(line 11) I have downloaded the TextIO file...I am not sure how to debug this,
Any help will be greatly appreciated ^.^
 
author & internet detective
Posts: 39283
727
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code should be



This tells Java that the method might (or might not) throw an IOException when running.
 
Greenhorn
Posts: 18
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have any idea what you did with the line but as far as i know, surrounding the statement with a try catch or adding to your main method signature will definitely make it work.
 
Sarah Singh
Greenhorn
Posts: 13
1
C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne Boyarsky

Gotchya! Thanks for clarifying that When I apply the edits,I think it goes into an infinite loop...since its not producing any output...unless I am doing something wrong :\



===========================================================================================
@Debdeep Ganguly

Yes! The code works with the suggested ammendment! Although I do not get the expected results

-------------------------------
Expected output

Help on:
1. if
2. switch
3. while
4. do-while
5. for
Choose one:
4
The do-while
do{
statement;
}while(condition);

--------------------------------------
Output after suggested ammendment

Help on:
if:
switch:
while:
do - while:
for
:
choose one:
 
Marshal
Posts: 5988
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What could you do to get the expected results?
 
Rancher
Posts: 3353
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Safe programming note: When coding a switch statement ALWAYS have a default: case that prints out a message saying what is wrong and shows the invalid input.
 
Marshal
Posts: 64493
225
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't use System.in.read(). It is a really awkward method to use. Try a Scanner, and you can use the words as options in the switch statement.
 
Sarah Singh
Greenhorn
Posts: 13
1
C++
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone who looked into my problem ^.^ And thanks for all the suggestions <3
This is really silly, but I realized thatsome of my print statements are wrong which is why I am not getting expected output D:
Sorry about that :'( Also, there was a bug in java.io.IOException Line which in now fixed \(^.^)/
Regards

Editted Code


 
author
Posts: 23832
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for providing your solution ... have a cow.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!