Suppose we have a class Worldand we have declared an instance of dreamWorldthis class. How is case 1 different from case 2 except that it is one line shorter? What difference does the instances make in the second case? I mean, after being the dreamWorldsame in both cases, right?
Case 1 :
void changeWorld(World outerWorld) {
World dreamWorld;
dreamWorld = outerWorld;
}
Case 2 :
void changeWorld(World outerWorld) {
World dreamWorld;
dreamWorld = new World();
dreamWorld = outerWorld;
}
where outerWorldis the class object Worldcreated elsewhere and, say, provided as an argument to the method (I'm not sure if it matters how it is provided).
PS
, , ( , , , , , ).