Forums Register Login

Difference between identifier and keyword

+Pie Number of slices to send: Send
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 ?
+Pie Number of slices to send: Send
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



+Pie Number of slices to send: Send
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.

There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4344 times.
Similar Threads
java
A very basic ques...
JDBC Help figuring it out
keywords or reserved words?
Reserved word and Key word
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:39:13.