Day 4 || Data Types and operators

Sdílet
Vložit
  • čas přidán 5. 07. 2024
  • In Java, data types are divided into two categories: primitive data types and reference (or non-primitive) data types. Each serves a different purpose and has its own characteristics.
    Primitive Data Types
    Primitive data types are the most basic data types available within the Java language. There are eight primitive data types:
    byte:
    Size: 8-bit
    Range: -128 to 127
    Example: byte b = 100;
    short:
    Size: 16-bit
    Range: -32,768 to 32,767
    Example: short s = 10000;
    int:
    Size: 32-bit
    Range: -2^31 to 2^31-1
    Example: int i = 100000;
    long:
    Size: 64-bit
    Range: -2^63 to 2^63-1
    Example: long l = 100000L;
    float:
    Size: 32-bit
    Range: Approximately ±3.40282347E+38F
    Example: float f = 10.5f;
    double:
    Size: 64-bit
    Range: Approximately ±1.79769313486231570E+308
    Example: double d = 10.5;
    boolean:
    Size: 1-bit
    Values: true or false
    Example: boolean isJavaFun = true;
    char:
    Size: 16-bit (Unicode)
    Range: 0 to 65,535
    Example: char letterA = 'A';

Komentáře •