What are Identifiers in JAVA ? | Java Basics-2 | Java E-Learn Platform @StudyEcart

Identifiers or User defined Words are simple names that will be used to identify the programming elements. For Example: Classes,methods,variables,.etc..
Main Rules should follow to define Identifiers:
  • Rule-I: When you declare Identifier, you can take Alphabet, Digits, and two special symbols,i.e Dollar[ $ ] and Underscore [ _ ]
  • Rule-II: Always take the first character must be Alphabet or Dollar [ $ ] or Underscore [ _ ]
  • Rule-III: Shouldn't take Reserved words or Keywords as Identifiers
  • Code Example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    package elearn.studyecart.basics;
    
    //public class 12IdentidersEx { // not valid Identifier
    public class IdentidersEx {
    
    	public static void main(String[] args) {
    	
           int var=100;//valid Identifier
           
        //   float 1value=123; // Not valid Identifier
           
           String intfloat="StudyEcart";//valid Identifier
           
           String get_Name="Pedro";//valid Identifier
           
           byte small$val=100;//valid Identifier
    			
    	}
    
    }
    
                                                                                                                                                                        

    Post a Comment

    0 Comments