Day-4 Data Types

Published: (January 30, 2026 at 09:22 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Data types

Data types are the kinds of information stored in a variable (e.g., numbers, characters, true/false, etc.).

There are two categories of data types:

  • Primitive data types
  • Non‑primitive data types

Primitive data types

TypeSize (bytes)Size (bits)
Byte18
Short216
Int432
Long864
Float216
Double416
Char18
Boolean1 (bit)

Note: Boolean occupies 1 bit (the smallest addressable unit is typically 1 byte).

Non‑primitive data types

String

  • String values are enclosed in double quotation marks (").
  • A String can store any text, including:
    • Names → "John"
    • Sentences → "I love programming"
    • Numbers as text → "12345"
    • Symbols → "@#$%"
    • Addresses → "New York, USA"

Internally, a String stores a sequence of characters.

Back to Blog

Related posts

Read more »

JDK

What is JDK? JDK is a complete software package used to develop Java applications. It contains tools to write, compile, debug, and run Java programs. When is J...

Operators

What are Operators in Java? Operators are symbols used to perform operations on variables and values. Types of Operators in Java - Arithmetic Operators - Assig...