Private void test () throws sqlexception {
Resultset rs = query ();
Closeall (RS );
System. Out. println ("535 ...... test of Java object passing:" + RS );
Rs. Close ();
Rs = NULL;
}
Private void closeall (resultset RS) throws sqlexception {
If (RS! = NULL ){
Statement stmt = NULL;
Connection con = NULL;
Stmt = Rs. getstatement ();
Con = stmt. getconnection ();
Rs. Close ();
Rs = NULL;
Stmt. Close ();
Stmt = NULL;
Con. Close ();
Con = NULL;
}
}
Output result: 535 ...... test resultset: org. Apache. commons. DBCP. delegatingresultset @ 2fae4a
--------------
I have set rs = NULL in the closeall method. Why can I print this object? Why not print null?
When an object is passed in Java, the referenced value is copied and transferred; a referenced copy is created. Rs = NULL modified the referenced copy and did not modify the original reference.
However, both references point to the same object. In fact, Rs. Close () has closed the RS object ..
Http://blog.csdn.net/zhaoqiubo/archive/2004/10/27/zhaoqiubo13.aspx
System. Out. println ("535 ...... test of Java object passing:" + RS );
The RS printed here is only a handle, not the actual value of Rs. It seems that the address of a place is "No. 100 Earth Road". One day, the building in this place was demolished, although there is no building, this place is still called "No. 100 earth road", but you can build a new building again.
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/zhaoqiubo/archive/2004/10/27/154958.aspx