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 »

Day-3 details of Class and Object

Class - Class is a Java keyword - Class is a template - Class is a logical entity - First letter of the class name should be capital CamelCase, e.g., SalaryAcc...

Instance(Object) Variable

What is an Instance Variable in Java? - An instance variable is a variable that belongs to an object instance of a class. - Every object gets its own copy of t...