Advertisement

Primitive data type & Reference data type in Java

In Java, there are two types of data types: primitive data types and reference data types.


Primitive data types are basic data types that are built into the programming language and include:


  • boolean: A boolean value can be either true or false.
  • char: A char value represents a single character, such as 'a' or '#'.
  • byte: A byte is an 8-bit signed integer.
  • short: A short is a 16-bit signed integer.
  • int: An int is a 32-bit signed integer.
  • long: A long is a 64-bit signed integer.
  • float: A float is a single-precision 32-bit IEEE 754 floating point.
  • double: A double is a double-precision 64-bit IEEE 754 floating point.

Reference data types are objects that are created from classes and include:


  • String: A string is a sequence of characters.
  • Array: An array is a collection of elements of the same data type.
  • Class: A class is a blueprint for creating objects.
  • Interface: An interface is a template that defines a set of related methods that a class can implement.

In Java, all objects are reference data types, while primitive data types are not objects.


Primitive Data Type & Reference Data Type



Post a Comment

0 Comments