Java Programing laungage

Core Java Tutorial

Introduction of Core Java

How To Install JDk and Set of Path

Syntax of java Program

Difference between Java and C/C++

Advantage and Disadvantage of Java

What is Java

Why Java is not Pure Object Oriented Language

Java has Following Features/Characteristics

Limitation of Java Language and Java Internet

Common Misconception about Java

Simple Program of Java

Integrated Development Environment in java

Compile and Run Java Program

Applet and Comments in Java

Tokens in Java

Keywords in Java

Identifier and Variables in Java


Data Type in Java

Assignments and Initialization in Java

Operators in Java

Rule of Precedence in Java

Operator on Integer and Separators in Java Programming

Java Control Flow of Statements

If and If-else Selection Statement

Nested If-else and If-else-If Selection Statement

switch case and conditional operator Selection Statement

for and while Loop

do..while and for each Loop

break and labeled break statement

continue and labeled continue statement

return Statement and exit() Method

Escape Sequence for Special Characters and Unicode Code

Constants and Block or Scope

Statement in Java

Conversions between Numeric Types in Java

Import Statement in Java

User Input in Java using Scanner Class

User Input in Java using Console Class

Array in Java

One Dimensional Array

Two Dimensional Array

Two Dimensional Array Program

Command Line Argument in Java

String args Types in Java

Uneven/Jagged array in java

Math Class Function and Constant

Math Class all Function used in a program

Enumerated Types in Java

Object Oriented Programming v/s Procedural Programming

Object Oriented Programming Concepts in Java

Introduction to Class,Object and Method in Java

Class Declaration in Java

Class & Objects in java

Encapsulation in Java

Modifiers/Visibility for a Class or Interrface or member of a Class

Polymorphism in Java

Runtime polymorphism (dynamic binding or method overriding)

Previous Home Next

Java is a strongly typed language so there must be a data type associated with every variable declared. Mainly there are eight primitive data types which are used in the java. Out of the eight data types used 4 are integer data types, 2 are float data types, one is character type and last but not the least is Boolean type data type. Now we shall see all these data types in detail :


Integer data types are used for integral numbers i.e. the numbers that do not have fractional parts. For Integer types there are four kind of data types are used in java, each having different storage capacity and range and based upon that they can be categorized as under :

byte1-128 to 127
short2-32768 to 32767
int4-2147,483,648 to 2147,483,647
long8-9,223,372,036,854,775,808 to -9,223,372,036,854,775,807

In java the ranges of the integer data types does not depend upon the machine on which you are executing your java code, their ranges are fixed, but unlike, in C++ or C the values of the integer data types changes if there is a change in the platform. Following show the way how we can write various integer literals in java :

  1. int literals are written in decimal notation as usual like 123 or -23445.

  2. long literals are written in decimal notation but postfixed by an L, eg 234556L or -56467776768L.

Note: Java does not have unsigned types.


Floating-point types are the numbers that are having fractional part. Based upon the storage capacity and range they can be categorised into the following types :

float4approx 3.40282237E+38 F
double8approx 1.79769312486231570E+308 D

Here, double corresponds to the fact that, it has double precision than that of float types, that's why double are also referred as double precision numbers. For floating-point types, we mostly use the double types, because of the fact that float has a less precision so it may be incompatible for certain type of calculations that require more precision.

For writing float literals we just postfixes F after the number as 4343.45455F, and a number not followed by F, will be simply termed as double by default.


Java Character type are the alphabets which are written in single quotes. It is basically a 16-bit unicode character, its minimum value is \u0000(which equals to 0) and maximum is \nFFFF(which equals to 65,535). Since it is a 16-bit unicode character so it takes 2 bytes in the memory upon declaration, while in C a character literal takes 1 byte in the memory.

For eg. char 'H'; is a character.


Boolean types are usually used for checking the logical conditions. These data types have two values true and false and also you cannot use integers instead of boolean values in java as you use in C or C++.

If you will use if(z=0) statement, in C or C++ it will compile but in java it will not compile and will give compilation error.

Previous Home Next