Difference between these two code snippets
Hi,
Can any one tell me the difference between the following two code snippets any specific advantage of using the first one.
I've a final boolean variable "readOnly" in the class. and the following method
private final void setReadOnlyPolicy(Connection c) throws SQLException {
boolean readOnlyPolicy = readOnly;
if (c.isReadOnly() != readOnlyPolicy) {
// read only policy of the connection is different than specified,
// change it
c.setReadOnly(readOnlyPolicy);
}
}
Cann't we write it like
private final void setReadOnlyPolicy(Connection c) throws SQLException {
if (c.isReadOnly() != readOnly) {
// read only policy of the connection is different than specified,
// change it
c.setReadOnly(readOnlyPolicy);
}
}
Regards,
Rakesh

