File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Passing References and Passing Values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passing References and Passing Values" Watch "Passing References and Passing Values" New topic
Author

Passing References and Passing Values

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, I have a question about Calling and Returning Objects. I am using a Connection example that I am doing, but this question really isn't about JDBC.

Now I am going to grab this connection from another Class

Now for my question. When I close the Connection I grabbed from Foo, is that closing THE connection from Foo or is that closing a different connection and so I will have some lingerning open connection I don't know about?


GenRocket - Experts at Building Test Data
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
The two con references are pointing to the same Connection object, not copies.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Great thanks. Now, tell me if there are any advantages/disadvantages to these two different methods of doing this:
METHOD 1

METHOD 2

[ September 25, 2002: Message edited by: Gregg Bolinger ]
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Someone pointed out that declaring utility methods as static has less overhead. Hope this thread helps.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Exactly what I wanted to know. Thanks.
 
jQuery in Action, 2nd edition
 
subject: Passing References and Passing Values