Programming

Java – Basic Terms of Java Programming

A Java program, similar to programs in other programming languages, It also uses the literals, variables, tokens, data types, etc.

Some of the features are derived from previous high-level programming languages like C, C++, like every programming language, and can have its own predefined keywords.

They can use the identifier to give a unique name and they can use comments to make code understandable.

Java Tokens

Tokens are the smallest units of Java that are used to create Java programs. Tokens can have their own rules to implement. Mainly there are six types of tokens that are used in Java. 

  1. Keyword
  2. Separator
  3. Identifier
  4. Operator 
  5. Literal
  6. Comment

Keyword

Keywords are the predefined words that can have some special meaning in particular programming.

Keywords can not be reused as a variable or methods or classes in a program. The list of a keyword which is predefined in Java is given below.

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

Separator

Simply separators are known as symbols which are used to give a better structure to the Java program or which helps to write a program in a well-defined manner.

To arrange the Java program code in a well-defined manner we use some special symbols,

  1. Parentheses () – contains parameter and used to m.
  2. Braces  {} – values automatically initialize arrays.
  3. Brackets [] – declare the array type
  4. Comma    ,  – separator
  5. Semicolon  ;  – terminates the statement
  6. Period         .  – separate the variable and object
  7. Colon      : – for loops

Operators 

An operator is a token that allows a programmer to perform a certain operation on data and variables.

Literal 

Java program you can assign a literal value to a variable. Literal refers to the constant values that can be changed depending on the program requirement.

The source code representation of the values of primitive data types in a Java program. 

Binary Literal

The binary literal express the integral type values in the binary number system. They are introduced in Java 7 specified by adding the prefix 0b or 0B to the number.

byte thisbyte = (byte) 0b00100011;
short thishort = (short) 0b0010011101000111;

The binary literals are useful in a number of programming task to be performed. The literals are frequently used to create numeric arrays.

int[] myarray = {
0b00110011;
0b11001100;
0b00110011;
}

Underscore in Numerical Literal

Underscore is used to make code is more readable. Long numerical literals, a feature has been introduced in Java 7, which allows you to use underscore in numeric literals.

You can use any number of underscore character(_) to break the groups of digits in the long numeric literals. 

long myNumber = 232_23234_4343_5445_3434;
long myHex = 0xvBAF_BAB;
  1. You can use start or end of the numeric literal.
  2. Use next to the decimal point in the floating point literal.
  3. Use in front of an F or L suffix in the long numeric literal.
  4. Place where a string of digits is exacted in the numeric literal

Comment

Comment are special tokens which are used to make more readable code. If any other programme use your program source code for further development he should have to understand the code.

Comments are ignored by Java compiler during the compilation of Java program. They are used to describe the function of the particular part of program. 

//this is single line comment
/* this is multiple line comment

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.