Trying to use IntStream.range () and getting "This static method is only available ..."

I am using IBM JVM 8 and Eclipse. I want the iterator to use a range of integers.

So I am trying to use IntStream.range () and get weird error. I have now removed the iterator part to get a minimal example of the problem. This line throws an error:

IntStream range = IntStream.range(0,max);

      

Error: This static method of the IntStream interface is only available as IntStream.range

But isn't that how I already refer to him? How can I get it to work without errors?

(I could of course use a loop instead of an iterator, but an iterator would be neater).

+3


source to share


1 answer


Referring to IntStream java doc and Compatibility Guide for JDK 8
Interface IntStream

dates back only to Java 1.8.
Use the "JavaSE-1.8" runtime match on the Java build path and rebuild the project.



+4


source







All Articles