如何在IntelliJ IDEA中启用Java的”Stream.of”方法。

huangapple go评论71阅读模式
英文:

How can i turn on "Stream.of" method in intellij IDEA for Java

问题

无法在 'Stream' 中使用 'of' 方法。我尝试了不同的Java版本作为项目SDK(8、11、14),但仍然出现相同的错误。

无法解析 'Stream' 中的 'of' 方法

示例图片链接

英文:

I can't use method 'of' in 'Stream'. I tried different java version as project SDK(8, 11, 14) but still get same mistake.

Cannot resolve method 'of' in 'Stream'

image of how it looks for example

答案1

得分: 1

代码部分不要翻译。

英文:

The syntax is correct. The language level does not matter here as Streams were introduced in Java 8.

So,

  1. Check your imports first of all. Make sure you are using java.util.stream.Stream:
    如何在IntelliJ IDEA中启用Java的”Stream.of”方法。

  2. Check also, that public static<T> Stream<T> of exists in your SDK (Cmd/Ctrl+Click on Stream). 如何在IntelliJ IDEA中启用Java的”Stream.of”方法。

  3. If it is there, try clearing caches of the IDE (File | Invalidate caches and Restart)

huangapple
  • 本文由 发表于 2020年9月22日 09:50:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/64002013.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定