Friday, 16 November 2018

Data types in Java | Java programming Data Type | Online Help

So, we are going to discuss java programming data type that is Data type in java. guys lets gets started, Data types are means to identify the type of data and associated operation for handling it. every variable in Java has data types. for this reason, Java is referred to as a strongly typed language. Data type specifies the size and type of values that can be stored. There is eight primitive data type available in java.(boolean,char,byte,short,int,long,float,and double).


Byte:

The smallest individual type is called as a byte. This is signed 8bits data type. It can be ranged from -128 to 127.
Example
byte b,c;

Short:

It is assigned 16 bits data type. it can be ranged from -32,768 to +32,767.
Example:
short a;

Int:

It is a signed 32 bits data type.It can be ranged from -2,147,483,648 to +2,147,483,647.
Example
int a,b;

Long:

It is signed 64 bits data type.It can be ranged from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.
Example
long a;

Floating-point data type: 

Floating-point types are used to store fractional numbers i.e. the numbers with one type of data is assigned to another type of variable, automatic type conversion will take place. if the following two conditions are met:
1. The two types are compatible.
2. The destination type is larger than the source type decimal point.
Java has two floating-point types:
1.float 
2.double

1.Float:

Variable of type float represent single precision floating-point number and have 7 significant digits.it has 32 bit data type.it can be ranged from 3.402823e38 to -1.401298e-45 for the negative value and 1.401298e-45 to 3.402823e38. for positive value.
Example
float avg

2.Double:

Variable of the type of double represent double [precision floating point number and have 15 significant digits. It has 64 bits data type.it can be ranged from 1.7e-308 to  1.7e+308.
Example
double a,b;

Character:

The char data type is used to represent a single or group of characters.char types contains 2 bytes(16 bits) but basically it can hold a single character.it can be ranged from 0 to 65535.

Boolean:

Boolean type is used to when we want to test a particular condition during the execution of the program. Boolean can store only true or false values.

No comments:

Post a Comment