For Programmers: Free Programming Magazines  


Home > Archive > Java Help > September 2006 > Newbie question on identifiers for basic catch statements









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie question on identifiers for basic catch statements
akh2103@gmail.com

2006-09-18, 10:03 pm

Hello--I am new to Java and having trouble with the identifiers that
are expected in catch statments. My compiler is telling me that it
doesn't recognize the symbols that I give in catch statements, but I
can't find a site online that explains how the identiers work. I am
trying to do really basic stuff ex.
Try{
do stuff
}
Catch (Some Exception Identifier){
do other stuff
}

but again, I can't get the compiler to take all of the identifiers that
I give. I know the identifiers must come from the inherited class, but
that isn't helping me much.

The error that the compiler gives looks like this
Program6.java:25: cannot find symbol
symbol : class InputMismatchException
location: class QuestionTwoShot
} catch (InputMismatchException e) {
^
1 error

Any help (or even better, explanation) would be much appreciated.
Thanks.

Ralf Seitner

2006-09-18, 10:03 pm

[...]
> The error that the compiler gives looks like this
> Program6.java:25: cannot find symbol
> symbol : class InputMismatchException
> location: class QuestionTwoShot
> } catch (InputMismatchException e) {
> ^
> 1 error

Hi!
You didnt import the class, so the compiler doesnt know where to find it.
Import it with "import java.util.ImportMismatchException"

Example:

import java.util.ImportMismatchException;
public class QuestionTwoShot {
....
}

bye, Ralf
Knute Johnson

2006-09-18, 10:03 pm

akh2103@gmail.com wrote:
> Hello--I am new to Java and having trouble with the identifiers that
> are expected in catch statments. My compiler is telling me that it
> doesn't recognize the symbols that I give in catch statements, but I
> can't find a site online that explains how the identiers work. I am
> trying to do really basic stuff ex.
> Try{
> do stuff
> }
> Catch (Some Exception Identifier){
> do other stuff
> }
>
> but again, I can't get the compiler to take all of the identifiers that
> I give. I know the identifiers must come from the inherited class, but
> that isn't helping me much.
>
> The error that the compiler gives looks like this
> Program6.java:25: cannot find symbol
> symbol : class InputMismatchException
> location: class QuestionTwoShot
> } catch (InputMismatchException e) {
> ^
> 1 error
>
> Any help (or even better, explanation) would be much appreciated.
> Thanks.
>


InputMismatchException is in the java.util package. Did you import
java.util?

--

Knute Johnson
email s/nospam/knute/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com