A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
passing primitive variables KB(chap3)
Joined: Feb 18, 2007
Jun 27, 2007 20:52:00
How program flow is going on please explain in detail
public static void main(
Dimension d=new Dimension(5,10);
ReferenceTest1 rt=new ReferenceTest1();
System.out.println("Before modify() d.height="+d.height);
System.out.println("After modify() d.height="+d.height);
void modify(Dimension dim)
Joined: Sep 11, 2006
Jun 27, 2007 22:05:00
Everything in Java is pass-by-value.
For primitives, you pass a copy of the actual value.
For references to objects, you pass a copy of the reference.
The example given to you is for reference to object.
Take a look at this link and try to understand how pass-by-value works in Java.
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
Joined: Aug 31, 2004
Jun 27, 2007 22:34:00
when posting code. Thanks!
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award."
It is sorta covered in the
JavaRanch Style Guide
subject: passing primitive variables KB(chap3)
Garbage Collection Problem Explain Pls Dan Chisholm single topic
passing primitive and reference variables to a method
uestion on pass byobject and pass by value.
Passing Object Reference Variables
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013