• 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

try...catch blocks giving <identifier> expected error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I've been working on some code and am trying to get exception handling to work in a few places. But whenever i put in the try catch blocks i get a compile error. I've been looking at this for hours and still can't figure it out. Does anybody have any ideas?

Here's my compiler errors:

jbw_OfficeTest.java:35: <identifier> expected
catch(InputMismatchException){

jbw_OfficeTest.java:61: <identifier> expected
catch(InputMismatchException){


Here's my code:
 
author
Posts: 23949
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Weiss wrote:Here's my compiler errors:

jbw_OfficeTest.java:35: <identifier> expected
catch(InputMismatchException){

jbw_OfficeTest.java:61: <identifier> expected
catch(InputMismatchException){




Your syntax is incorrect. Take a look at some examples in the Java exceptions tutorial, and you'll see that you are missing something.

http://java.sun.com/docs/books/tutorial/essential/exceptions/

Henry
 
John Weiss
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhh, I sure do feel dumb now. Thanks a ton!
 
Marshal
Posts: 79072
376
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also search for InputMismatchException on this forum; you will find ways to avoid it completely. Maybe here, or here, and while we are at it, here is a different pitfall with Scanner.
 
reply
    Bookmark Topic Watch Topic
  • New Topic