Introduction to Java

Tutorial Difficulty Level    

JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was conceived by James Gosling and Patrick Naughton. It is a simple programming language.  Writing, compiling and debugging a program is easy in java.  It helps to create modular programs and reusable code and is ‘platform independent’.

To understand the meaning of platform independent, we must need to understand the meaning of platform first. A platform is a pre-existing environment in which a program runs, obeying its constraints, and making use of its facilities.

Getting back to the point. During compilation, the compiler converts java program to its byte code. This byte code can run on any platform such as Windows, Linux, Mac/OS etc. Which means a program that is compiled on windows can run on Linux and vice-versa. This is why java is known as platform independent language.

Jav is also an Object-orientated programming language: Except for the primitive data types, all elements in Java are objects.

Primitive types are the most basic data types available within the Java language.  Thier are 8 of them :

  • boolean (true or false). The Default for a boolean in Java is false.
  • byte(8 bit signed integer).

for example:

The number 65 is the code for ‘A’ in ASCII.

  • char(a character).  char can be created from character literals and numeric representation. Character literals consist of a single quote character ( ‘ )(ASCII 39, hex 0x27), a single character, and a close quote ('), such as 'w'. Instead of a character, you can also use unicode escape sequences.

for example:

Output for the above:

65 is the numeric representation of character ‘A’ , or its ASCII code and ‘\u0014’ is the unicode escape sequence.

  • short(16 bit signed integer)

for example:

  • int(32 bit signed integer)

for example:

  • long(64 bit signed integer)

for example:

  • float(32 bit float)

for example:

  • double(64 bit float)

for example:

These types serve as the building blocks of data manipulation in Java. Such types serve only one purpose — containing pure, simple values of a kind.