Some notes in Stanford CS106A(2)
Some notes in Stanford CS106A(2)
1.Local variable(local)
ex. int i = 0; factorial(i);
the “i” outside the method factorial(i) is called local variable ; and the “i” in method factorial(i) is a copy of the “i” outside
instance variable(ival) | local variable(local) |
declared in class | declared in method |
visable in entity object | vis in method |
lives ala object lives | lives in method |
state | local competition |
2.Class variable(static variable)
A variable that is shared by all objects of that class.
ex.public static int Counter;
IF “Counter” is setting to another num, the one who used the class which include the Class var , will get the new num.
like ,
Public class ClassCounter { public ClassCounter (){ counter=1; }; public ClassCounter (int count){ counter=count; }; public int getnum(){ return counter; } private static int counter; } ... ClassCounter counter1 = new ClassCounter(); ClassCounter counter2 = new ClassCounter(1000); println(counter1.getnum()); //the printout is 1000
3.Javadoc for ACM libraries
http://jtf.acm.org/javadoc/student/
4.getters and setters—-the difference with public:
setter is used to make sure the value we want to set is right, if not right ,we can prevent changing the value. (more details please refers to other docs. like
https://www.cnblogs.com/Jac440682/p/6752152.html
5.stacking order(z-order) sth. used in acm.graphics(略,非重点)