Home | Unit 1 | Unit 2 | Unit 3 | Unit 4 | Unit 5 | Unit 6 | Unit 7 | Unit 8 | Unit 9 | Reflection |
Unit 5
My notes on unit 5.
Classes
This is basically unit 2 but more in depth.
Remember that Static methods / variables belong to the class, not the object.
The this
keyword works like self
in python, referring to the class itself.
Mutator Methods
Mutator Methods modify an object’s state by changing the value of its fields or attributes
Accessor Methods or getters allow you to access data
Mutators or setters are weirdly enough a type of mutator method, they just modify data
Java convention is for getters to be called getVariableName()
and for setters to be called setVariableName()
Scope in Java
In Python, the only scopes are the local (function) and global scope (technically you can have nested scopes with nested functions but the point still stands).
In Java, even something like an if statement or a loop starts a new scope.