Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing References and Passing Values

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The two con references are pointing to the same Connection object, not copies.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone pointed out that declaring utility methods as static has less overhead. Hope this thread helps.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly what I wanted to know. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic