Atomic Elements of Java Program and Keywords

                 Atomic Elements of Java Program

  1. Whitespace

  2. Identifiers

  3. Literals

  4. Comments

  5. Separtors

  6. The Java Keywords


Whitespace:

Java is a free form language. This means that you do not need to follow any special indentation rules. So you could write all on one line or in any way you like as long as there is one whitespace between each token. In java, whitespace is a space, tab or newline.

Identifiers:

Identifiers are used for class names, method names, and variable names. An identifier may be any sequence of alphabets, numbers or underscore and dollar sign. They must not begin with a number. Java is case sensitive Language. So Hello is different from HELLO.
Valid Identifiers are:          Avg     Hello    What_012     $gh
Invalid Identifiers are:       2kjj     hell-o    hell/o

Literals:

A constant value is created in java by using literals representation of it.
Exp:             456           85.5    "This is a Literal"         'Y'

Comments:

There are three of comments in java: Single-line, multiline and documentation comment.

Separtors:

There are few characters that are used as separators.These are as under:
()  Parentheses  Contain lists of parameters in method definition and invocation. Used for defining precedence in expressions, containing expressions in control statements, and surrounding cast types.
{} Braces         Contain the values of automatically initialized arrays. Also used to define block of code, for classes, methods, and local scopes.
[]  Brackets      For declaring array types and dereferencing array values.
;    Semicolon   Terminates statements.
,    Comma       Separates consecutive identifiers in a variable declaration. Also used to chain statements together inside a for statement.
.    Period         Used to separate package names from sub-packages and classes . Used to separate a variable or method from a reference variable.

The Java Keywords:

There are 48 reserved keywords currently defined in Java language. These keywords, combined with the syntax of the operators and separators, from the definition of Java language. These keywords cannot be used as names for a variable, class or method.

 Java Keyword:

abstract   boolean   break   byte   case   catch   char   class   const   continue   default   do   double   else   extends    final        finally    float   for      goto    if       implements     import      instanceof    int    interface
long         native      new     package       private   protected   public   return      short     static      strictfp
super       switch      synchronized       this      throw      throws     transient     try     void    volatile   while

Written By: Asad Hussain

Post a Comment

Previous Post Next Post