HIT 2020Spring Software Construction 0317

Types in Java

Primitives will be stored on stack and only values will be stored.
Object reference types will be stored on heap and their id will also be stored other than values.

Static Checking and Dynamic Checking

Static checking is done in the compile process and it will make sure values match the certain types.
While dynamic checking is processed in the run time. Dynamic checking tends to find a specific value valid or not in a particular situation.
Generally speaking, dynamic checking is more strict than static checking. Code without any kind of type checking will have lowest cost but have many annoying problems.
When it comes to java, it is a statically-typed language while Exception performs like dynamic checking.

Mutability and Immutability

It is a very important part in the exam and we may be asked to analyse a mutable class and transfer it to a immutable one.
Difference between two kinds of objects
To transfer a mutable class to a immutable class, we need to make the property to be final and private. And for those mutable property, the getter method should give a copy of the property instead of a reference. This is called defensive copying.
We should be aware the relationship between the reference and value.

It is only a post for what I want to record for the specific course and it does not stand for the whole content.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值