Tuesday, June 8, 2021

Primitive data type in java

                                                        Java: Primitive data types

The eight primitive data types in Java are:

  • boolean, the type whose values are either true or false
  • char, the character type whose values are 16-bit Unicode characters
  • the arithmetic types:
    • the integral types:
      • byte
      • short
      • int
      • long
    • the floating-point types:
      • float
      • double

Values of class type are references. Strings are references to an instance of class String.


Primitive data types in Java
TypeDescriptionDefaultSizeExample Literals
booleantrue or falsefalse1 bittruefalse
bytetwos complement integer08 bits(none)
charUnicode character\u000016 bits'a''\u0041''\101''\\''\'''\n''ß'
shorttwos complement integer016 bits(none)
inttwos complement integer032 bits-2-1012
longtwos complement integer064 bits-2L-1L0L1L2L
floatIEEE 754 floating point0.032 bits1.23e100f-1.23e-100f.3f3.14F
doubleIEEE 754 floating point0.064 bits1.23456e300d-1.23456e-300d1e1d








No comments:

Post a Comment