A blog for computer science passionates.

Tuesday, 11 February 2020

Various Data Types in Java

Hello Friends!!!

In this article, we are going to learn different data types in Java. Java is a strongly (Strict) typed programming language. i.e. all the variables or expressions must have data types as Java compiler checks whether the variable or expression is compatible with data or not. There are two different types:
  • Primitive
  • Non - Primitive
Primitive Data Types: In simple words, primitive data types mean primary data types, as we all know that we have different data such as numeric data or a character type of data based on the types of data Java defines different data types. such as integer, float, long, short, byte, double, character and boolean.

Non-Primitive Data Types: These data types works on arrays, string or class or interfaces, etc. generally, non-primitive datatypes made with primary (primitive) data types.


Data type
Range
Size (Bits)
Group
byte
–128 to 127
8
Integer
short
–32,768 to 32,767
16
Integer
int
–2,147,483,648 to 2,147,483,647
32
Integer
long
–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
64
Integer
float
1.4e–045 to 3.4e+038 (Approx)
32
Floating Point
double
4.9e–324 to 1.8e+308 (Approx)
64
Floating point
char
0 to 65,536
(\u0000 to \uFFFF)
16
Character
boolean
true / false
1
Boolean


Table.1 Primitive Datatypes

Java supports eight different primary data types with four different groups as you can see in the table. In the next article, we will learn more about data types i.e. how to work on these data types? till then enjoy Java and start with Hello World Coding.
Happy Coding...☺

No comments:

Post a Comment