While looking through the Java API source code I often see method parameters reassigned to local variables. Why is this ever done?
void foo(Object bar) {
Object baz = bar;
//...
}
This is in java.util.HashMap
public Collection<V> values() {
Collection<V> vs = values;
return (vs != null ? vs : (values = new Values()));
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…