0
public class WeatherAggregator {
private List<WeatherSource> weatherSources;
public WeatherAggregator(List<WeatherSource> weatherSources) {
this.weatherSources = weatherSources;
}
public double getTemperature() {
return weatherSources
.stream()
.mapToDouble(WeatherSource::getTemperatureCelcius)
.average()
.getAsDouble();
}
}
我搜索了這裏的&這個符號是什麼意思,但是我找不到任何意義呢?! 你能說出這一行發生了什麼嗎?這個&符號在這方面的用途是什麼?
private List<WeatherSource>weatherSources;
我發現在互聯網上的代碼通過在DIP原理教程 – titorat
方式這意味着你無意中撿到了一些HTML中的源代碼。應該說'List'。 –
非常感謝!你解決了我的問題,但如果你有時間,請考慮告訴究竟是什麼「HTML被選中」,因爲我有點好奇! 再次感謝:) – titorat