wood burning stoves 2.0*
The moose likes Java in General and the fly likes Difference between identifier and keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference between identifier and keyword" Watch "Difference between identifier and keyword" New topic
Author

Difference between identifier and keyword

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
Whats the difference between identifier and keyword.

I read this "You can use assert as a keyword or as an identifier but not both" What does this mean ?
Swati Save
Greenhorn

Joined: Mar 06, 2010
Posts: 14
Keywords are reserved words like(static,public......) which has a special meaning for compilers.

Identifier can be name of any variable or any name used to identify an object or entity .hence keywords cannot be used as an identifier



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

There are a few exceptions, mostly caused by changes during a major Java version upgrade.
- Java 1.4 introduced assertions. "assert" became a keyword. You can turn this off by using the compiler flags (-source 1.3) to use Java 1.3 source compatibility, thereby using the keyword "assert" as an identifier
- Java 5.0 introduced enumerations. "enum" became a keyword. See the above; -source 1.4 allows you to use enum as an identifier.

Both will still show a warning but it will no longer be an error.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: Difference between identifier and keyword