Are true
and false
keywords in Java?
Asked
Active
Viewed 5,564 times
5 Answers
27
Here's the complete list of Java Language Keywords. In particular, note that
true
,false
, andnull
might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.

Zach Scrivena
- 29,073
- 11
- 63
- 73
-
-
It's syntactical. Literals represent values, like "Hello" and 42, whereas keywords don't. – Zach Scrivena Feb 23 '09 at 01:26
-
-
1"Keywords" and "literals" are mutually exclusive, by their definition. – Zach Scrivena Feb 23 '09 at 01:39
-
i the java language specification, it says "The tokens are the identifiers (§3.8), keywords (§3.9), literals (§3.10), separators (§3.11), and operators (§3.12) of the syntactic grammar.". so by saying "false, ..." is not a keyword, that maybe simplifies matters. i dunno – Johannes Schaub - litb Feb 23 '09 at 01:55
-
Thanks Zach. Now bookmark the link, it will refrain you from posting lot of other questions. – Adeel Ansari Feb 23 '09 at 02:03
-
1
No. true and false are literals in java. Literals are something which are actual values not the variable names. Though they are not part of keywords list of java they are considered to be the reserved ones. If you try to use them as variables you will get compile error saying - invalid VariableDeclaratorId

Rishikesh Dhokare
- 3,559
- 23
- 34
1
No true, false are not keywords they are actually literals; you cannot use them as identifiers in your programs. Here is the complete list of keywords in java
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while
* not used
** added in 1.2
*** added in 1.4
**** added in 5.0

Sunil Kumar Sahoo
- 53,011
- 55
- 178
- 243