2017-06-04 46 views
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; 
+0

我發現在互聯網上的代碼通過在DIP原理教程 – titorat

+0

方式這意味着你無意中撿到了一些HTML中的源代碼。應該說'List '。 –

+0

非常感謝!你解決了我的問題,但如果你有時間,請考慮告訴究竟是什麼「HTML被選中」,因爲我有點好奇! 再次感謝:) – titorat

回答

4

它只是<>的HTML源編碼。以下:

List&lt;WeatherSource&gt; 

實際上

List<WeatherSource> 

看到這裏的HTML escape characters

+1

謝謝你!你救了我的腦袋:) – titorat