尝试使用IntStream.range()并获取“只能访问此静态方法...”(Trying to use IntStream.range() and getting “This static meth

编程入门 行业动态 更新时间:2024-10-06 20:33:28
尝试使用IntStream.range()并获取“只能访问此静态方法...”(Trying to use IntStream.range() and getting “This static method can only be accessed…”)

我正在使用IBM JVM 8和Eclipse。 我想要一个整数范围的迭代器。

所以我尝试使用IntStream.range()并得到一个奇怪的错误。 我现在已经删除了迭代器部分以获得问题的最小示例。 此行导致错误:

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

错误是:接口IntStream的这个静态方法只能作为IntStream.range访问

但这不是我的访问方式吗? 如何在不产生错误的情况下使其工作?

(当然我可以使用循环而不是迭代器,但迭代器会更整洁)。

I am using IBM JVM 8 and Eclipse. I want an iterator over a range of integers.

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

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

The error is: This static method of interface IntStream can only be accessed as IntStream.range

But isn't this how I am accessing it already? How can I get it to work without producing errors?

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

最满意答案

参考IntStream java doc和JDK 8兼容性指南 Interface IntStream仅在Java 1.8之后才出现。 在Java Build Path上使用执行环境'JavaSE-1.8'的合规性并重建项目。

Referring to the IntStream java doc and Compatibility Guide for JDK 8 Interface IntStream is only brought up since Java 1.8. Use compliance from execution environment 'JavaSE-1.8' on the Java Build Path and rebuild the project.

更多推荐

本文发布于:2023-07-27 04:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1284895.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:静态   方法   range   IntStream   method

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!