中级农民
- 积分
- 109
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2020-5-28
- 最后登录
- 1970-1-1
|
Week 2 Mon (day 1):
看完了lecture,总结下:
- Java has 9 data types, 8 of them are primitive types and the last one is reference type
- int a = 1
declare type int, name it a -> create 32 bit -> set the value of that location to 1
- Dog a = new Dog()
declare type reference type, intended to store only Dog objects, initially with value null -> find enough space to store the object, use constructor to construct the instance, returns the memory location -> assign the memory location to a
- int[] a = new int[]{1,2,3}
declare type reference type, intended to store only int arrays, initially with value null -> find enough space to store the array (length of 3), use constructor to create the instance, returns the memory location -> assign the memory location to a
- Copy values:
When we copy values, we copy whatever the value is in the bits. If it's a primitive type, these bits represent values. If it's a reference type, these bits represent address of the referenced object.
- Passing params:
In java, all params are passed by copying the arguments to variables local to the function. (Pass by value). Again, this value might represent an actual value (int, string), or an address of an object
- 最后提到了IntList,就是LinkedList, 不过只适用于int
|
|