- 博客(7)
- 收藏
- 关注
原创 软件构造笔记——OOP(面向对象编程)
面向对象编程的几个基本概念Object拥有一组状态(statestatestate,即fieldsfieldsfields)和行为(behaviorbehaviorbehavior,即methodmethodmethod)。Classes每一个对象都有一个类用来描述其状态和行为,其中MethodsMethodsMethods和fieldsfieldsfields统称为membersmemb...
2019-06-24 20:20:54 257
转载 转载:java中成员变量和局部变量在内存中的分配
对于成员变量和局部变量:成员变量就是方法外部,类的内部定义的变量;局部变量就是方法或语句块内部定义的变量。局部变量必须初始化。 形式参数是局部变量,局部变量的数据存在于栈内存...
2019-06-17 11:21:43 1117 1
原创 软件构造笔记——可变性的危害
Risks of mutationRisky example #1:passing mutable values以下为一个计算list中各数之和的方法:/** @return the sum of the numbers in the list */public static int sum(List<Integer> list) { int sum = 0; ...
2019-06-16 20:18:57 271
原创 软件构造笔记——Mutability and Immutability
Mutability and Immutability1.1 Immutability(不变性)不变性是一种主要的设计原则,包括:Immutable types(不变数据类型):不变数据类型创建完后,值不可修改。Immutable references(不变引用):一旦指定引用位置,不可再次指定。final关键字对不可变类型提供了静态检查的支持:A final class d...
2019-06-16 20:17:31 242
原创 软件构造笔记——Type checking
Type checkingStatic checkingDynamic checkingThe bug is found automatically before the program even runs.静态检查针对类型,与变量特定值无关的错误。The bug is found automatically when the code is executed.动态检查怎对...
2019-06-16 20:12:55 594
原创 软件构造笔记——java中的数据类型
Data type in programming languages1.1 Types and VariableTypes: A type is a set of values, along with operations that can be performed on those values.Variables: Named location that stores a val...
2019-06-16 20:00:53 141
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人