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.

 

转载于:https://www.cnblogs.com/morningdew/p/5618472.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值