*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Does this create another instance ?" Watch "Does this create another instance ?" New topic
Author

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, ..) {
classOne.doSomething(..);
}
}
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Yes, that is correct.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Does this create another instance ?
 
Similar Threads
Protected Behaviour
Passing a refrence to another Class vs method
Best design approach
Simple interface & constructor question
OO doubt