What's the difference between literals and keywords - I have read that true, false and null are all literals and not keywords(I always thought the literals are - literals ) and I'm a bit confused here so if someone could shed some light...
Cheers, B. [ November 22, 2003: Message edited by: Bojan Knezovic ]
The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (�3.8): [the list of keywords goes here] The keywords const and goto are reserved, even though they are not currently used. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs. While true and false might appear to be keywords, they are technically Boolean literals (�3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (�3.10.7). A literal is the source code representation of a value of a primitive type (�4.2), the String type (�4.3.3), or the null type (�4.1): Literal: IntegerLiteral FloatingPointLiteral BooleanLiteral CharacterLiteral StringLiteral NullLiteral
Vad is right -- according to the JLS, "null", "true" and "false" are literals and not keywords. BUT.... for the purposes of the exam -- don't worry about it.
From the SCJP 1.4 Exam objectives Section 4: Language Fundamentals * Identify all Java programming language keywords. Note: There will not be any questions regarding esoteric distinctions between keywords and manifest constants.