“import java.util.function无法解析”错误 [英] The "import java.util.function cannot be resolved" error
问题描述
我正在尝试运行此练习脚本来自标准Oracle Java教程。
这似乎是一个常见错误,我使用了SO资源来尝试解决这个问题。我已经尝试过清理项目,刷新项目,切换工作区并切换回来,删除并重新添加JRE7。
This seems to be a common error and I've used SO resources to make attempts to fix this. I've tried Cleaning the project, refreshing the project, switch workplace and switch back, removed and re-added the JRE7.
我不知道还能做什么。
import java.util.List;
import java.util.function.Consumer; -----> cannot be resolved ERROR
import java.util.function.Function; -----> cannot be resolved ERROR
import java.util.Comparator;
import java.util.function.Predicate; -----> cannot be resolved ERROR
import java.lang.Iterable;
import java.time.chrono.IsoChronology; -----> cannot be resolved ERROR
public class LambdaExpressions_RosterTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
推荐答案
根据 java.util.function
Javadoc,
Per the java.util.function
Javadoc,
Since:
1.8
因此升级到Java 8,或尝试查找本教程的旧版本。
So upgrade to Java 8, or try to find an older version of the tutorial.
我是新来的。你怎么知道你在跑什么?我正在使用Eclipse
I'm new at this. How can you tell what you are running? I'm using Eclipse
要确定您在eclipse中的当前Java版本,请转到
To determine your current Java version in eclipse, go to
Help -> About Eclipse -> Installation Details (Button in
lower Left) -> Configuration pane
查找 java.specification.version $ c行$ c> - 在我的机器上
Look for the line java.specification.version
- on my machine that is
java.specification.version=1.8
或者我的机器上的 java.runtime.version
-
Or the line java.runtime.version
- on my machine that is
java.runtime.version=1.8.0_11-b12
这篇关于“import java.util.function无法解析”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!