Primitive Data Types in Java

Primitive Data Types, Wrapper Class, Overflow / Underflow and Casting

Norine Oo
The Startup

--

I have been learning “Java” programming language recently and I want to share what I have learned during the process of my learning journey so that it would be useful for someone who is also learning Java and at the same time, it is helpful for me to revise what I have learned through sharing my work.

In this article, I want to talk about Primitive Data Types, Wrapper Class, Overflow/Underflow and Casting in Java.

Primitive Data Types

Primitive data types are the most fundamental data types in Java. There are eight primitive data types - byte, short, int, long, float, double, char and boolean. In programming, it is crucial to practise relevant data type.

byte, short, int, long

Data types - byte, short, int, long involve whole numbers (no fractions), which can be either positive or negative. The type int is the default value in Java and if there is no data type specified to a particular value in a variable, Java will assume that value as int value.

Data type, byte is the smallest type, which takes 8 bits (1 byte) and this type is useful in saving memory. Data type, long is the largest type, which takes 64 bits (8 bytes) of memory and has the capability to store a large number of value sufficiently.

float, double

--

--

Norine Oo
The Startup

Full Stack Developer 👩‍💻 | Passionate about software development | 📍Australia