+ 13
Only car3 and car2 is equal. car1 = new Car(); car1 is now the value of a new instance of the class car. car2 = new Car(); Same thing with car2, the instances are independant. car3 = car2 This assigns the value of the reference (or 'memory location') of car2 to car3. So, lets say we did: car2.setSpeed(100); That would be the same as doing: car3.setSpeed(100); Both the variables point to the same object. car2 == car3 // true
28th May 2018, 12:07 PM
Rrestoring faith
Rrestoring faith - avatar