COMP 202 Lecture Notes - Lecture 26: Local Variable, Global Variable
jc123 and 40170 others unlocked
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
The this keyword is use to refer to the object on which a non-static method was called. Instead of passing v as input, we can use the this keyword inside the print method to refer to it. No! this refers to the object instance that calls the method. A static method is called from the name of the class, and not from a particular object. The static method wold have nothing to refer to. In a static method, you would use the name of the class instead of the word this if you wanted to specify the global vs local variable. Add a method getmagnitude to the vector class. Recall that the magnitude of a vector v with dimension d. We"ll make this static, so you don"t need to pass a vector as input, you can call it on a particular vector.