Pages

May 31, 2015

[CS61B] Notes for class 2-Defining classes




Java gives a default constructor that takes no parameter, does no initializing. However, if we write a constructor, the default constructor goes away.

Static field: a single variable shared by a whole class of objects. Also called class variables.
e.g. System.in & System.out are static fields.

Static method: Doesn't implicitly pass an object as a parameter.
main() is always static.
IMPORTANT: In a static method, THERE IS NO "this".


No comments:

Post a Comment