It's not a secret anymore!
The moose likes Beginning Java and the fly likes Does this create another instance ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does this create another instance ?" Watch "Does this create another instance ?" New topic

Does this create another instance ?

Steve Yu
Ranch Hand

Joined: Mar 26, 2003
Posts: 60
public class Test {
public void doAct1() {
ClassOne one = new ClassOne();
doAct2(one, ...);
public void doAct2(ClassOne classOne, ..) {
Question --- in method "doAct2", the parameter "classOne" is just another reference to the instance "one" created in method "doAct1", right ? In other words, the pgm doesn't create another instance of "ClassOne" in "doAct2" method, right ?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Yes, that is correct.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Does this create another instance ?
It's not a secret anymore!