I am trying to understand something that may be very simple, so I apologize if I am looking like a rookie.
I have this java class:
public class Student {
public String name = "";
public int age = 0;
public String major = "Undeclared";
public boolean fulltime = true;
public void display() {
System.out.println("Name: " + name + " Major: " + major);
}
public boolean isFullTime() {
return fulltime;
}
}
And this class from which I call the first one:
public class TestStudent {
public static void main(String[] args) {
Student bob = new Student();
Student jian = new Student();
bob.name = "Bob";
bob.age = 19;
jian = bob;
jian.name = "Jian";
System.out.println("Bob s Name: " + bob.name);
}
}
This will print:
Bob s Name: Jian
I am curious about how the assignments are done there.
bobandjianis referring to the same object.