aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 19541
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between identifier and keyword
 
Similar Threads
Reserved word and Key word
A very basic ques...
java
keywords or reserved words?
JDBC Help figuring it out