Java Data Types

The Shortcut
1 min readDec 30, 2022

--

In Java, there are two categories of data types:

  1. Primitive data types: These are the basic data types that are predefined in Java and are not objects. There are 8 primitive data types in Java:
  • boolean: Represents a boolean value, either true or false.
  • char: Represents a single character, such as 'a', 'b', 'c', etc.
  • byte: Represents an 8-bit integer value.
  • short: Represents a 16-bit integer value.
  • int: Represents a 32-bit integer value.
  • long: Represents a 64-bit integer value.
  • float: Represents a single-precision floating point value.
  • double: Represents a double-precision floating point value.
  1. Reference data types: These are objects that are created from classes, and they hold a reference to the object in memory. Some common reference data types in Java include:
  • String: Represents a sequence of characters.
  • Array: Represents a collection of elements of the same type.
  • List: Represents an ordered collection of elements that can be modified dynamically.
  • Set: Represents a collection of unique elements.
  • Map: Represents a collection of key-value pairs.

It’s important to choose the appropriate data type for your variables, as this can affect the memory usage and performance of your program.

Find out more about Java here:

--

--

The Shortcut

Short on time? Get to the point with The Shortcut. Quick and concise summaries for busy readers on the go.