October 2008
Beginner to intermediate
680 pages
16h 48m
English
In client code, such as the Main method of a program, we declare reference variables with which to store references to objects:
Student s = new Student(); // a reference variable of type Student
and can then conveniently access the objects that these reference variables refer to by manipulating the reference variables themselves:
s.Name = "Fred";
When we're executing the code that comprises the body of one of an object's own methods, we sometimes need the object to be able to refer to itself—that is, to self-reference—as in this next bit of code:
public class Student
{
Professor facultyAdvisor;
// other details omitted
public void SelectAdvisor(Professor p) {
// We're down in the "bowels" of the SelectAdvisor() ...Read now
Unlock full access