Private void test () throws sqlexception {resultset = query (); closeall (rs); system.out.println ("535 ........ About Java object delivery test ResultSet: 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 = null;
} Print outcome: 535 ........ About Java objects Passset: org.apache.commons.dbcp.dlegatingResultSet@2fae4a -------------- I am RS = null; why can I print out this object? Why don't you print NULL? When you pass an object in Java, it is a replication transfer to the referenced value; create a copy of the referenced. RS = NULL modifies the referenced copy and does not modify the original reference; so it is printed. However, these two references points to the same object, in fact rs.close () has turned off the RS object. .