lec13 - Lecture 13 Memory model of objects Objects as...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CS125 Course Notes Lecture 13, Slide 1 Lecture 13 •Memory model of objects •Objects as parameters (Savitch 4.3)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 13, Slide 2 References • Example: String greeting = "Hello!"; String hi = "Hello!"; String goodbye = "Good bye!"; System.out.println(greetings == hi); // will print "false" because the objects have different // references in the memory. goodbye = hi; System.out.println(goodbye); // Output ______________ System.out.println(goodbye == hi); // will print "true" because both objects have the same // reference now.
Background image of page 2
CS125 Course Notes Lecture 13, Slide 3 Tracing through the example 1380 Good bye! 1317 Hello! 1250 Hello! 1008 1250 greeting 1004 1317 hi 1000 1380 goodbye String greeting = “Hello!”; String hi = “Hello!”; String goodbye = “Good bye!”; System.out.println(greetings == hi);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS125 Course Notes Lecture 13, Slide 4 Tracing through the example 1380 Good bye! 1317 Hello! 1250 Hello! 1008 1250 greeting 1004 1317 hi 1000 1317 goodbye goodbye = hi; System.out.println(goodbye == hi);
Background image of page 4
Course Notes Lecture 13, Slide 5 Passing parameters • In Java, parameters are passed-by-value . • That is, we cannot change the value of the
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/27/2009 for the course MATH 135 taught by Professor Andrewchilds during the Fall '08 term at Waterloo.

Page1 / 22

lec13 - Lecture 13 Memory model of objects Objects as...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online