Quand je lis le code source à partir de java.io.BufferedInputStream.getInIfOpen(), je ne comprends pas pourquoi il a écrit un code comme celui-ci:
/**
 * 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;
}Pourquoi utilise-t-il l'alias au lieu d'utiliser la variable de champ indirectement comme ci-dessous:
/**
 * 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;
}Quelqu'un peut-il donner une explication raisonnable?
ifdéclaration?
                
Eclipse, vous ne pouvez pas suspendre un débogueur sur uneifinstruction. Peut- être une raison pour cette variable alias. Je voulais juste jeter ça là-bas. Je spécule, bien sûr.