Zum Inhalt springen

Today I Learned in Java -Data types and variables..

Data Types:

In java there are two types of data types:

  • Primitive data type.

  • Non-Primitive data type.

Primitive data type:

Primitive data types are the basic building blocks that store simple values directly in memory.Primitive data types are fixed.

  • boolean

  • char

  • byte

  • int

  • short

  • long

  • float

  • double

Boolean:

  • Stores true or false values

char:

  • char Stores a single character/letter or ASCII values

byte:

  • Stores whole numbers from -128 to 127

    int:

    • Stores whole numbers from -2,147,483,648 to 2,147,483,647
      ## short:
  • Stores whole numbers from -32,768 to 32,767

long:

  • Stores whole numbers from -32,768 to 32,767

float:

  • float temperature = 36.6f;

  • This stores a decimal number representing body temperature.

double:

  • Stores fractional numbers. Sufficient for storing 15 to 16 decimal digits

Non-Primitive data type:

Non primitive data types are non fixed They are ,

  • string

  • object

  • array

Variables:

Data types are used in variable,there are two types are variables they are,

  • Local variable

  • Global variable

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert