第二章: Everything is an Object

第二章: Everything is an Object

1Where storage lives:

  1. Registers.

  2. The stack.

  3. The heap.

  4. Static storage. 

  5. Constant storage. 

  6. Non-RAM storage.

2Special case: primitive types

Primitive type

Size

Minimum

Maximum

Wrapper type

boolean

Boolean

char

16-bit

Unicode 0

Unicode 216- 1

Character

byte

8-bit

-128

+127

Byte

short

16-bit

-215

+215—1

Short

int

32-bit

-231

+231—1

Integer

long

64-bit

-263

+263—1

Long

float

32-bit

IEEE754

IEEE754

Float

double

64-bit

IEEE754

IEEE754

Double

void

Void

3Arrays in Java

When you create an array of objects, you are really creating an array of references, and each of those references is automatically initialized to a special value with its own keyword: null.

You can also create an array of primitives. Again, the compiler guarantees initialization because it zeroes the memory for that array.

4Creating new data types: class

When a primitive data type is a member of a class, it is guaranteed to get a default value if you do not initialize it:

Primitive type

Default

boolean

false

char

‘/u 0000’ (null)

byte

(byte)0

short

(short)0

int

0

long

0L

float

0.0f

double

0.0d

This guarantee doesn’t apply to “local” variables—those that are not fields of a class. Thus

5Comments and embedded documentation

There are two primary ways to use javadoc: embed HTML or use “doc tags.” Standalone doc tags are commands that start with a ‘@’ and are placed at the beginning of a comment line.

There are three “types” of comment documentation, which correspond to the element the comment precedes: class, variable, or method.

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值