Professional Documents
Culture Documents
Java Data Types: Spotle - Ai/learn
Java Data Types: Spotle - Ai/learn
Java Data Types: Spotle - Ai/learn
ai Study Material
Spotle.ai/Learn
Char b = ‘r’;
Data Types refer to the type of data you will store in a variable. For
example a variable can be of type number, string or an object of a
custom class.
byte short
int long
float double
boolean
Floating
Integer
Point
int long
(4 bytes) (8 bytes)
Character Boolean
char boolean
(2 bytes) (1 byte)
There are 4 types of integer data types in Java – byte, short, int, long.
//A byte type variable takes 1 byte of storage and can store values from -128 to 127
byte a = 2;
//The short data type is a 16-bit. It has a minimum value of -32,768 and a maximum value of
32,767
short b = 156;
//The int data type is a 32-bit signed two’s complement integer, taking values from -2^31 to
2^31-1
int c = 32769;
//The long data type is a 64 bit’two’s complement integer taking values from -2^63 to 2^63-
long l = 24678822;
There are 2 types of floating point data types in Java – double and
float.
//double data type is a double-precision 64-bit IEEE 754 floating point. Its
value range is unlimited.
double d = 4.54877;
A boolean type is declared with the boolean keyword and only takes
the values true or false:
Non-Primitive
Datatypes
String s = “hello”;
System.out.println(“The length of s is ” + s.length());//outputs The length
of s is 5
interface Security
{
boolean accessCheck(String employeeToken);
}