What is happening when this code declares course2 = course1; Because what happens after that I can't make sense of. If I comment out course2 = course1; I get Programming Fundamentals twice.
public Course(int courseID, String courseName) {
ID = courseID;
name = courseName;
}
public String getName() {
return name;
}
public void setName(String newName) {
name = newName;
}
public static void main(String[] args) {
Course course1 = new Course(2531, "Programming Fundamentals");
Course course2 = new Course(1285, "Algorithms and Analysis");
System.out.println(course1.getName());
course2 = course1;
course2.setName("PF");
System.out.println(course1.getName());
}
This outputs as:
Programming Fundamentals
PF