Data Types in Java

Posted morningdew

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Data Types in Java相关的知识,希望对你有一定的参考价值。

In Java, Data types are classified into two categories:

1. Primitive Data Type

2. Non-Primitive Data Type

 

there are 8 primitive data types:

char  boolean  byte  short  int   long   float  double

 

8 primitive can be classfiied into 4 groups;

 

group 1: Integer

byte : It is 8 bit integer data type. Value range from -128 to 127. Default value zero. example: byte b=10;

short : It is 16 bit integer data type. Value range from -32768 to 32767. Default value zero. example: short s=11;

int : It is 32 bit integer data type. Value range from -2147483648 to 2147483647. Default value zero. example: int i=10;

long : It is 64 bit integer data type. Value range from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value zero. example: long l=100012;

 

group 2: Floating-Point Number

float : It is 32 bit float data type. Default value 0.0f. example: float ff=10.3f;

double : It is 64 bit float data type. Default value 0.0d. example: double db=11.123;

 

group 3: characters

char : It is 16 bit unsigned unicode character. Range 0 to 65,535. example: char c=‘a‘;

 

group 4: boolean

This group represent boolean, which is a special type for representing true/false values. They are defined constant of the language. example: boolean b=true;

 

2) Non-Primitive (Reference) Data Type:

A reference data type is used to refer to an object. A reference variable is declare to be of specific and that type can never be change. We will talk a lot more about reference data type later in Classes and Object lesson.

 

以上是关于Data Types in Java的主要内容,如果未能解决你的问题,请参考以下文章

All data types in Python are “reference type“

All data types in Python are “reference type“

MongoDB - The mongo Shell, Data Types in the mongo Shell

Primitive Types in Go

[TypeScript] Understand lookup types in TypeScript

JavaScript data types and data structures