这个&符号在这方面的用途是什么?

问题描述:

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

它只是<>的HTML源编码。以下:

List&lt;WeatherSource&gt; 

实际上

List<WeatherSource> 

看到这里的HTML escape characters

+1

谢谢你!你救了我的脑袋:) – titorat