【发布时间】:2015-06-20 10:48:03
【问题描述】:
我正在使用 IntelliJ IDEA 学习算法,第 4 版,但是,我遇到了一个问题,IDEA 告诉我“无法解析符号 'StdIn' 和 'StdOut'”。
图片:[无法解析符号“StdIn”](http://i.imgur.com/ZRD6o53.jpg)
我的项目结构是正确的,我将stdlib.jar设置为依赖项之一,其中有StdIn和StdOut。即使我点击了“使缓存失效并重新启动”,问题仍然存在。
您可以从here和Average.java了解stdlib.jar的详细信息
public class Average {
// this class should not be instantiated
private Average() { }
/**
* Reads in a sequence of real numbers from standard input and prints
* out their average to standard output.
*/
public static void main(String[] args) {
int count = 0; // number input values
double sum = 0.0; // sum of input values
// read data and compute statistics
while (!StdIn.isEmpty()) {
double value = StdIn.readDouble();
sum += value;
count++;
}
// compute the average
double average = sum / count;
// print results
StdOut.println("Average is " + average);
}
}
【问题讨论】:
-
如果您将图片上传到公共站点并编辑您的问题以链接到该图片,则具有较高声誉的人可以将链接替换为嵌入的图片。话虽如此,您没有理由不能将代码作为文本包含在问题中,以及错误消息的完整和准确文本。
-
这两堂课你
import了吗? -
你是从书中逐字复制代码吗?
-
@azurefrog 我只是发布一些我想上传的图片的链接。
-
@Makoto 是的。您可以看到我在上面发布的
Average.java的代码。
标签: java intellij-idea