Technology News, Online Income, Gadgets, Reviews

Technology News, Gadgets and Reviews

Translate

Breaking

Total Pageviews

Sunday, January 15, 2023

Identifiers In Java

   Java Identifiers 

Any name in java consider as identifier which is used for identification purpose. 

  •  Identifier can be class name 
  • Identifier can be Label name
  • Identifier can be Variable name 

Allowed Character in java identifiers are : 

  • A to Z
  • a to z
  • 0 to 9
  • _underscore Symbol

$Dollor Symbol also can use: 

  • Eg : total_number

Identifier Cant start with Number : 

  • Eg ;00122value

 We can use numbers after the any letters:

  • Eg : suresh123

Java identifier are Case Sensitive: 

Eg : 

  • int number =10;
  • int Number = 10;
  • int NUMBER =10;

 These three variables are different because java is case Sensitive 


No length restriction in identifier in java :

  • Eg : int Sureshkumarbajeer = 10; (Its valid)


We can't use reserved in java identifiers :

Eg : int if =10;    String Case = "Suresh";

if we use reserved word like (if ) then we will get compile time error. 


We can use pre define class as identifiers : 

int String = 10;  (It's Valid)


Valid Declaration in Java : 

int Int 10;

String string ="Suresh";

int total =10;

int _totoal = 10;

int $cash =10;


-> In java version 9  _Underscore is a keyword . Cannot be used as identifier in the java . 

-> But we can use _Underscore as the identifier till 8.0 version. 

No comments:

Post a Comment