DEV Community

Dev Ananth Arul
Dev Ananth Arul

Posted on

Java Data Types

Java is statically typed programming language which means variable types are known at the compile time.

  • In Java, compiler knows exactly what types each variable holds and enforces correct usage during compilation. For example "int x = "GfG";" gives compiler error in Java as we are trying to store string in an integer type.

  • Data types in Java are of different sizes and values that can be stored in a variable that is made as per convenience and circumstances to handle different scenarios or data requirements.
    Java Data Type Categories:

  1. Primitive Data Type: These are the basic building blocks that store simple values directly in memory. Examples of primitive data types are boolean, char, byte, short, int, long, float and double.

    2.Non-Primitive Data Types (Object Types): These are reference types that store memory addresses of objects. Examples of Non-primitive data types are String, Array, Class, Interface and Object.

Top comments (0)