Some notes in Stanford CS106A(4)

时间:2022-06-13 18:45:15

1.x++ is a method , the return value is x. (post increment)

++x is also a method , the return value is x+1. (pre increment)

2.muti-dim Array

int[][] matrix = new int[2][3];

matrix[0][1] = 5;

3.Boxing : Creating an object around a particular primitive

Unboxing : getting the value out of the box

4.array and ArrayList

Pros of ArrayList : dynamic resizing , contains other operations

Cons of ArrayList : less efficient , syntax bulky ( error prone ) , pre java 5.0

If have fixed size , use array.

5.Map is a interface in java, it's to add Key and value pairs.

Dictionary is a map.

6.Iterator : list through set of values. Hashmap has no ordering , so we use Iterator get the order. ( ex. it.next() )