Error "cannot find symbol"

Hi i just started learning java. When i am taking input from the user using the following statement firstName=console.next(); compiler is giving me the error "cannot find symbol". Please help!
[206 byte] By [AshiKhuranaa] at [2007-10-3 9:45:02]
# 1
either give us all your code or the full error. :-)
Norweeda at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 2
We are not mind readers but most likely reason is you declared console out of scope, ie in another method or block of code.
floundera at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 3

Hi some tips for you.

import java.io.*;

public class InputExample

{

public static void main(String[] argv) throws IOException

{

// code needed for keyboard input

BufferedReader br = new BufferedReader(

new InputStreamReader(System.in));

String temp;

// rest of your program code here, as usual

}

}

Then whenever you wish to read something from the keyboard, simply write

temp = br.readLine();

If it is useful rate me duke dollars.

Thanks

Edward

edward_duraia at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 4

> If it is useful rate me duke dollars.

You are really on the Duke Dollars, Edward (this is not your only post in which you say this).

"Cannot find symbol" or anything like that means that you are using a variable that does not exist at the place you are using it. You might have misspelled the name (also note that variable names are case sensitive) or you have a scoping error.

jesperdja at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 5

A Java compiler doesn't just say "cannot find symbol"; the compiler

attempt to synthesize a useful error diagnostic message, i.e. it also

tells you *which* symbol it couldn't find and most (if not all) compilers

display a nice little caret symbol just below the name/symbol it was

unable to find.

Believe the compiler: if the compiler couldn't find that symbol you haven't

declared it in that particular scope or it couldn't be found due to classpath

reasons. Please do read the compiler diagnostic; it'll tell you everything

you always wanted to know and shouldn't have asked here.

kind regards,

Jos

JosAHa at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 6

> A Java compiler doesn't just say "cannot find

> symbol"; the compiler

> attempt to synthesize a useful error diagnostic

> message, i.e. it also

> tells you *which* symbol it couldn't find and most

> (if not all) compilers

> display a nice little caret symbol just below the

> name/symbol it was

> unable to find.

>

> Believe the compiler: if the compiler couldn't find

> that symbol you haven't

> declared it in that particular scope or it couldn't

> be found due to classpath

> reasons. Please do read the compiler diagnostic;

> it'll tell you everything

> you always wanted to know and shouldn't have asked

> here.

>

> kind regards,

>

> Jos

no, Jos, you're so wrong. so terribly terribly wrong. it's highly unlikely that a beginner would have made a mistake, remember. it's far more likely they've found a bug "in java"</sarcasm>

georgemca at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 7

> no, Jos, you're so wrong. so terribly terribly wrong. it's highly unlikely

> that a beginner would have made a mistake, remember. it's far more

> likely they've found a bug "in java"</sarcasm>

:-) Sometimes it makes me wonder why people ask "what does this mean"?

when they read, say, "else without if" spewed out by the compiler. I think

it has to do with the ancient art of reading ;-)

kind regards,

Jos ("bailing out near line 1")

JosAHa at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 8
funniest one I saw was "it says the class MyFrame2 must be declared in a file called MyFrame2. what do I do now?"I'm sure I work beside some of these people
georgemca at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 9

> funniest one I saw was "it says the class MyFrame2 must be

> declared in a file called MyFrame2. what do I do now?"

>

> I'm sure I work beside some of these people

lol!

A funny one I saw years ago was printed by a program itself; it printed

"ignore the null pointer assignment when process terminates". It was

a small C program run as a "small model" executable process. MS's

null pointer check could only check whether or not its first two bytes

were altered when the process was about to exit.

None of folks overthere paid any attention to that message ;-)

kind regards,

Jos

JosAHa at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 10

Not to defend the indefensible, but the error "Cannot find symbol" can be a bit cryptic to a beginner, as they have probably never heard of a "symbol" before. variable, yes, method, probably, bu symbol, I'll buy you a beer if somebody can tell me they heard that term in an intro to java class.

OTOH, you're correct in your view that alot of people who post can't read. I mean, they see the words, they type them in here, but they don't really READ them. Not to mention the fact that they all seem to be able to find this forum, yet can't seem to google the answer, so they ask the same questions over and over and over and over and... ad infinitum.

SomeoneElsea at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 11

"Cannot find symbol" is pretty cryptic, but it's never alone. there's always more description than that, and until one can make use of that information to debug their code, they won't be able to write code. simply pointing out what mistake they've made doesn't help them with that, it just defers their confusion until the next time they "cannot find symbol"

when someone can't resolve a "cannot find symbol"-type problem, the problem isn't that the compiler can't find the symbol, or whatever. the problem is that they haven't yet learnt how to resolve that kind of problem. every time someone else does it for them is another time they've been unable to do it themselves. struggle is natures way of strenthening us!

georgemca at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 12
> If it is useful rate me duke dollars.> > Thanks> EdwardTake it !
manuel.leiriaa at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...
# 13
Hey thanks Edward Your solution did not work but i used the BufferedReader. with the help of which i can take input.Thaks for ur help buddyAshish
AshiKhuranaa at 2007-7-15 5:01:37 > top of Java-index,Java Essentials,New To Java...