Likes

Keywords and Identifiers in Java

             
             We have learnt how to write and run a simple Java Program of Hello World.Now we have to move further with some other concepts involved in Java Programming.In this post , we will focus on two important things Keywords and Identifiers in Java,  which are the some of the many basics concepts required for programming in Java.




Keywords:-
  • In Java, a keyword is a word with a predefined meaning in Java programming language syntax.
  • Keywords are also called , sometimes, as 'reserved words'.
  • Keywords combined with operators and separators according to syntax form the foundation of the Java language . 
  • Java language has reserved 50 words as keywords.
  • They are as follows:-
  • Please read the following points carefully:

  1. const and goto are not currently in use.
  2. null, true, and false are reserved literals but can be considered as reserved words for the purpose of exam.
  3. All the Java technology keywords are in lower case. It is important to understand that Java language is case-sensitive. So even though final is a keyword, Final is not .
  4. strictfp is a new keyword added in Java 1.2 , assert is added in Java 1.4 and enum in Java 5.0
  5. The list of keywords as defined by Sun is present here.
  • The keywords const and goto are reserved , even though ther are not currently being used.
  • true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.
  • In most of integrated development environments (IDE's - Eclipse,Netbeans,Jcreator,etc.) it highlighted with different colour's.
  • No need to remember all the keywords at this point of time . Each keyword will be explained in further posts.
Identifiers:-
  • Identifiers are names we give to our variables, constants, classes and methods in Java Program. It is just like giving a name to a human ,a dog ,a cat ,a house or anything. 
  • Identifiers must comply with the following rules :-
  1. The first character of an identifier must be a letter, an underscore(_), or a dollar sign($).
  2. The rest of the characters in the identifier can be a letter, underscore, dollar sign or digit.
  3. Spaces are not allowed in identifiers.
  4. Identifiers are case-sensitive.This means age and Age are different identifiers.
  5. Identifiers cannot match any of the Java keywords i.e. reserved words .
  • Some examples of Identifiers :-
  1. age
  2. $post
  3. b4
  4. hello_world
  5. AvgSal
    
So, now we have learnt about the Keywords which are the special reserved words in Java and the identifiers which are the names given to particular things in Java.


KEEP COMPILING !!

Keywords and Identifiers in Java Keywords and Identifiers in Java Reviewed by shashank on 11:22 Rating: 5

No comments:

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks
Powered by Blogger.