In fact, Eckel's book, Thinking in Java, is one of the one's I was thinking of, that talks of Java as passing by reference. See Appendix A, Passing and Returning Objects.
- David Gallardo --- Java exams <[EMAIL PROTECTED]> wrote: > > For additional references, I suggest > Bruce Eckel's "Thinking in Java", and > the Java Language Specification. > > This is an item covered by the Sun Certified Java > Programmer Exam and an excellent example of > how firms are starting to "test" job applicants > on knowledge as part of the interview > process ( some using the program referred to > below ). Should a job applicant be excluded purely > on the results of such knowledge ( passing by value, > or is it a copy of the reference ) - no. Is it > best to be as prepared as possible? Yes. > > You might want to take a look at: > > http://www.enterprisedeveloper.com/jcertify > > Version 5.1 was recently released. > > Regards, > > Dave > > --- Tom Jordan <[EMAIL PROTECTED]> wrote: > > Nathan, <?xml:namespace prefix = o ns = > > "urn:schemas-microsoft-com:office:office" /> > > > > While I believe David's portrayal of me as a > > quibbling zealot is a bit > > harsh, he is right about one thing "(you) got the > > official terminology > > wrong", but you were right about how it worked. > > > > Java's argument passing is pass-by-value since in > > all cases the method > > receives a copy of the original (the definition of > > pass-by-value). When the > > argument is an object, the method is passed a copy > > of the original. Granted, > > it is a shallow copy (in fact, the shallowest of > > copies since only the > > reference to the object is copied), but it's a > copy > > never the less. > > Therefore, it completely satisfies the definition > of > > pass-by-value. > > > > Although I have never seen a published source > refer > > to this as > > "pass-by-reference" (as David claims), I do admit > > that when you said, "I > > understood passing a reference to an object to be > > termed pass by reference" > > you raise a legitimate point that often leads to > > confusion. > > > > Tom > > > > > > > > -----Original Message----- > > From: David Gallardo [ mailto:[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]> > > ] > > Sent: Friday, May 31, 2002 3:50 PM > > To: JDJList > > Subject: [jdjlist] Re: Java : pass by reference??? > > > > > > Semantics--he's quibbling with you about > semantics. > > In > > Java, some people don't like to call it "passing > by > > references." In certain quarters, they'll boo you > > down > > & not let you finish your sentence, if you use > that > > term. > > > > (Despite the references someone quoted, I can > think > > of > > a few other books that unabashedly call it passing > > by > > reference. But in any case, "appeal to authority" > is > > a > > weak argument.) > > > > It says something about the confusion this causes, > > that you, who got the official terminology wrong, > > are > > the only one who got the answer right! > > > > > > --- Nathan Tenney <[EMAIL PROTECTED]> wrote: > > > Perhaps I am wrong, but I understood passing a > > > reference to an object to be termed pass by > > > reference... > > > > > > --- Tom Jordan <[EMAIL PROTECTED]> wrote: > > > > Nathan, > > > > > > > > You are description of the "fillMe" argument > and > > > the > > > > effect of the "fill()" > > > > method is correct, but your assertion that > "Java > > > > does use pass by reference" > > > > is WRONG. > > > > > > > > The following statement is absolutely true: > > "Java > > > > passes all arguments by > > > > VALUE" (references listed below). > > > > > > > > When passing an Object it is the object > > reference > > > > that gets passed (not the > > > > object itself) and it is passed by value. In > > other > > > > words, a copy of the > > > > object reference is passed to the method. As > you > > > > correctly stated, this > > > > reference points the orginal object and can be > > > used > > > > to modify the orginal > > > > object thru its public mutator methods. > > > > > > > > Tom > > > > > > > > References: > > > > "Exploring Java" 2nd edition, O'Reilly, Pg 143 > > > > "Argument Passing and > > > > References" > > > > "Java 2 Certification Study Guide", Sybex, Pg > 17 > > > > "Argument Passing" > > > > > > > > > > > > > > > > -----Original Message----- > > > > From: Nathan Tenney [ mailto:[EMAIL PROTECTED] > > <mailto:[EMAIL PROTECTED]> ] > > > > Sent: Friday, May 31, 2002 12:36 PM > > > > To: JDJList > > > > Subject: [jdjlist] Re: Java : pass by > > reference??? > > > > > > > > > > > > Ok, I didn't take the time to read all the > > > messages > > > > in > > > > this thread, so someone may have already > > answered > > > > this > > > > to my satisfaction, but the 4 or 5 I did read > > had > > > it > > > > totally wrong. > > > > > > > > Java does use pass by reference. Think of the > > > > variable fillMe in your fill methods has > holding > > a > > > > reference to another object. At the beginning > > of > > > > the > > > > method, it refers to the object you passed in > > when > > > > you > > > > called fill. However, when you used new, you > > > > changed > > > > which object fillMe refers to, so any changes > > made > > > > to > > > > fillMe at this point will not touch the > original > > > > object fillMe referred to. NOTE: defining a > > > String > > > > explicitly (with "") is the same thing as > using > > > new. > > > > > > > > The major problem with your example is that > you > > > used > > > > immutable objects (String and Integer) as the > > > > objects > > > > to refer to. Immutable Objects are those that > > > have > > > > no > > > > methods for modifying the data that is stored > in > === message truncated === __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com To change your membership options, refer to: http://www.sys-con.com/java/list.cfm
