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:
byte b = 65;
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:
char oneChar1 = 65; char oneChar2 = '\u0041'; System.out.println(oneChar1); System.out.println(oneChar2);
Output for the above:
A A
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:
short age = 65;
- int(32 bit signed integer)
for example:
int age = 65;
- long(64 bit signed integer)
for example:
long timestamp = 1256480256;
- float(32 bit float)
for example:
float price = 56.99
- double(64 bit float)
for example:
double x = 783.65
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.