When I read the source code from java.io.BufferedInputStream.getInIfOpen(), I am confused about why it wrote code like this:
/**
 * Check to make sure that underlying input stream has not been
 * nulled out due to close; if not return it;
 */
private InputStream getInIfOpen() throws IOException {
    InputStream input = in;
    if (input == null)
        throw new IOException("Stream closed");
    return input;
}
Why does it use the alias instead of use the field variable in directly like below:
/**
 * Check to make sure that underlying input stream has not been
 * nulled out due to close; if not return it;
 */
private InputStream getInIfOpen() throws IOException {
    if (in == null)
        throw new IOException("Stream closed");
    return in;
}
Can someone give a reasonable explanation?
 
     
     
     
    