| Author |
what does "true" belong to?
|
William Yan
Ranch Hand
Joined: Sep 26, 2006
Posts: 69
|
|
Hi everybody, i am new here. i saw "true" and "false" do not belong to the keywords of JAVA while i cannot use them for variable names. So i wonder what do the "true" and "false" belong to? Are they just used for boolean-values and cannot be used anywhere else? And is there a naming rule says you cannot use them for names? Thanks
|
Java is better and better, yet bitter and bitter.
|
 |
Keith Lynn
Ranch Hand
Joined: Feb 07, 2005
Posts: 2341
|
|
|
true and false are boolean literals.
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Originally posted by William Yan: ...is there a naming rule says you cannot use them for names? Thanks
Welcome to JavaRanch! "An identifier cannot have the same spelling (Unicode character sequence) as a keyword (�3.9), boolean literal (�3.10.3), or the null literal (�3.10.7)." Ref: JLS - 3.8 Identifiers.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
William Yan
Ranch Hand
Joined: Sep 26, 2006
Posts: 69
|
|
Thank you, Marc. Definitely clear.
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hi, true, false and null are 3 reserved literals in Java. Regards, Jothi Shankar Kumar. S
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Rajesh Kadle
Greenhorn
Joined: Sep 06, 2004
Posts: 26
|
|
Hi, I have a question on boolean type. I read that 'boolean' doesnt have a size (like int-4, long-8 etc). So how does the compiler store these values in the class file or on the stack/heap. Can someone throw light on this. Thanks in advance, -Raj
|
 |
William Yan
Ranch Hand
Joined: Sep 26, 2006
Posts: 69
|
|
|
As "Head First Java" says, variables are stored in heap/stack according to whether it is used as instance variable(in class) or local variable(in method). But i dunno the size, and i think that does not matter much.
|
 |
 |
|
|
subject: what does "true" belong to?
|
|
|