Data Types in Java
Data Types in Java are the different values and sizes that can be stored in the variable according to the requirements.
Java Datatype are further two types:-
1. Primitive Data Type in Java
In Java, primitive data types serve as the foundation for manipulating data. They are the most basic types of data that the Java programming language uses. Java has several primitive data types, including:
Type |
Size |
Example Literals |
Range of values |
---|---|---|---|
boolean |
1 bit |
true, false |
true, false |
byte |
8 bits |
(none) |
-128 to 127 |
char |
16 bits |
𠆊’, ‘\u0041’, ‘\101’, ‘\\’, ‘\’, ‘\n’, ‘β’ |
characters representation of ASCII values 0 to 255 |
short |
16 bits |
(none) |
-32,768 to 32,767 |
int |
32 bits |
-2,-1,0,1,2 |
-2,147,483,648 to 2,147,483,647 |
long |
64 bits |
-2L,-1L,0L,1L,2L |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
float |
32 bits |
1.23e100f , -1.23e-100f , .3f ,3.14F |
upto 7 decimal digits |
double |
64 bits |
1.23456e300d , -123456e-300d , 1e1d |
upto 16 decimal digits |
2. Non-primitive Data Type
Non-primitive datatypes are created from primitive datatypes. Examples of non-primitive datatypes include arrays, stacks, and queues.
Java Cheat Sheet
Java is a programming language and platform that has been widely used since its development by James Gosling in 1982. It follows the Object-oriented Programming concept and can run programs written in any programming language. Java is a high-level, object-oriented, secure, robust, platform-independent, multithreaded, and portable programming language All those words are collectively called Java Buzzwords. It is commonly used for programming web-based, window, enterprise, and mobile applications. This Java Cheat Sheet article has been written by experts in Java and based on the experience of students who have recently undergone Java interviews.
This Core Java Cheat Sheet has been designed by Java experts, based on the experience of students who have recently undergone Java interviews. Whether you are a beginner or an experienced Java developer, this Java Cheat Sheet is a valuable resource for quickly accessing essential syntax, concepts, and best practices related to Java Programming.