Sunday, 7 February 2016

Identifiers and Reserverd words in JAVA

Identifiers: A name in a program is called an identifier. It can be used for representing a class name or interface name or method name or variable names




Rules for declaring Identifiers:
Rule 1: No identifier starts with number
                  ex. int 9a;
                       int a;
Rule 2: Allowed character set
                                a to z
                               A to Z
                              0 to 9 
                             special characters  _ ,$

Rule 3: There is no restriction for length of an      identifier name
Rule 4: Predefined class names method names are allowed to use as an identifier
Rule 5: in JAVA identifiers are case sensitive
Rule 6: Reserved words are not allowed to use as identifiers


Reserved Words / keywords:
    Some identifiers are reserved words. Which are called reserved words or keywords


                 

JAVA Reserved words:


Keywords used for primitive data types
     byte, short, int, long, float, double, char, boolean

Keywords used for flow control
        If, else, switch, case, default, for, while, do, break, continue, return

Keywords used for exception handling
     try, catch, finally, throws, throw

Keywords used for modifiers
        public, protected, private, static, abstract, final, synchronized,  volatile, transient, native, strictfp

Keywords used for class related
        class, extends, interface, implements, package, import

Keywords used for object related
        new, instanceof, super, this

Keyword used for return type
        void

Keyword used for debugging
       assert

Keyword introduced in JDK 1.5
       enum

No comments:

Post a Comment