X hits on this document

97 views

0 shares

0 downloads

0 comments

40 / 46

© S. Uchitel, 2004

40

Assignment

Careful with the assignment (“=”) operator:

For primitive types it copies values

Car myCar;

myCar = new Car(“blue”, “Torino”, 44);

Car yourCar = myCar;

yourCar.colour = “red”;

int e = 256;

int j =  1;  

j = e;

j++

256

257

Stack

e

j

Stack

myCar

yourCar

Heap

“Torino”

44

“red”

For reference types it copies references not objects!

Document info
Document views97
Page views97
Page last viewedSun Dec 04 02:06:18 UTC 2016
Pages46
Paragraphs816
Words2901

Comments