8

Are true and false keywords in Java?

Hank Gay
  • 70,339
  • 36
  • 160
  • 222
  • This question was in fact answered in your previous question on this topic: http://stackoverflow.com/questions/519631/java-keywords – Greg Hewgill Feb 23 '09 at 01:52

5 Answers5

27

Here's the complete list of Java Language Keywords. In particular, note that

true, false, and null 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
22

No. true and false are literals.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Warrior
  • 39,156
  • 44
  • 139
  • 214
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, but they're reserved.

Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78
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