Java - Core Java - Identifier


It is used to identify name, class name, method, variables, object name, interfaces, etc.
class A{
 public static void main(String args[])
  int x=12;


In the above example A, main, String, args and x are identifier.
  • Identifier include a to z, A to Z, 0-9, $
  • total_number (valid)
  • total# (invalid)
  • Identifier can’t stop with digits
  • total123 (valid)
  • 123total (invalid)
  • Uppercase and lowercase are differ meaning
  • Maximum characters are allowed there is no length limit
  • Reserved words are not allowed
  • All Java class names and interfaces names can use as identifiers, but it is worst kind of use
Reserved words
  • 53 Reserved words are there
  • 50 keyword 48 used 2 unused (goto, const)
  • Reserved literal( true, false, null)
  • Default return type is int
goto create several problems in old languages that is why Java banned go Instead const Already final is there
  • All reserved words in Java contains only lower case alphabet symbols
  • In Java we have only new and there is no delete keyword because distribution of useless object is the responsibility of garbage collection
  • strictfp comes in 1.2 version
  • assert comes in 1.4 version
  • enum comes in 1.5 version