Menu

Data Types in Java
πŸ“°

Data Types in Java

DEV Community: javaΒ·ABISHEK MΒ·8 days ago
#nwvP3pAJ
#devtojava#devto#dev#types#enter
Reading 0:00
15s threshold

Introduction

Data types are one of the fundamental concepts in Java programming.

Whenever we write a program, we need to store different kinds of information, such as numbers, names, decimal values, and true or false conditions.

Java provides different data types to store these values.

A data type specifies what kind of value a variable can store.

For example:

Age – Integer

Name – Text

Salary – Decimal number

Grade – Character

Passed – True or False

Let's understand data types in Java in detail.

1. Types of Data Types in Java

Java data types are divided into two major categories:

Primitive Data Types

Non-Primitive (Reference) Data Types

2. Primitive Data Types

Primitive data types are the basic built-in data types provided by Java.

Java has 8 primitive data types:

byte

short

int

long

float

double

char

boolean

Let's understand each data type.

1. byte

The byte data type is used to store small whole numbers.

Memory: 1 byte

Range: -128 to 127

Example:

byte age = 21 ; System .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.