BeignTech - Tech That Matters Indetifier In Java

Indetifier In Java

 A name in Java program is called identifier,it can be class name or variable name or method name or lable name.

Example.

             


👉 Rules of define indentifiers

  1.     The only allowed charaters in Java indentifiers are:
    1. A to Z
    2. a to z
    3. 0 to 9
    4. hyphen(-)
    5. dollar($)
  2. if we are using any other characters we will get completime error.
 public class Main {
  public static void main(String[] args) {
    // Good
    int 455 = 60;

    // OK, but not so easy to understand what m actually is
    int m = 60;
    
    System.out.println(455);
    System.out.println(m);
  }
}

Datatypes in Java 

Array In Java

OUTPUT 


   3. Indentifiers can't start with digit.
            Ex.
                    123abc  - Error
                    abc123 - Ok

  4. Java identifiers is casesensitive 
            Ex.
                    Class Test
                        {
                       int Number  = 10;
                        int Number = 20;
                        int Number = 30;                  
                        }

   5. Reserved words can't be used as identifiers (like a java keyword, such int or boolean).
   6. There is no limit for java indentifiers. But it's not recommanded to take morethan 15 lenght . (>15)
   7. all predefined java class names & interface name we can use as indetifiers. Eventhough it is legel but it is not recommanded.
            


Post a Comment

Previous Post Next Post