如何解决IntelliJ IDEA中的“无法解析符号”?

时间:2015-04-14 17:36:10

标签: java intellij-idea

我正在使用IntelliJ IDEA学习算法,第4版,但是,我鼓励IDEA告诉我“无法解析符号'StdIn'和'StdOut'”的问题。

图片:[无法解析符号“StdIn”](http://i.imgur.com/ZRD6o53.jpg)

我的项目结构是正确的,我将stdlib.jar设置为依赖项之一,其中有StdIn和StdOut。即使我点击“Invaildate缓存并重新启动”,问题仍然存在。

http://i.imgur.com/nVyoWP8.jpg

http://i.imgur.com/GvEwJtn.jpg

您可以从herestdlib.jar

了解Average.java的详细信息
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);
    }
}

P.S。:这个问题并没有解决我的问题。

2 个答案:

答案 0 :(得分:0)

当我没有定义变量并尝试使用它时,我通常会看到这一点,例如:

public class Animal {
    private String name;

    public String getName() {
        return name;
        address = new String(); // here I will see this error
    }

    public void setName(String name) {
        this.name = name;
    }
}

答案 1 :(得分:0)

这是因为stdlib.jar没有为其类定义包结构:(

尝试在默认包上创建您的类,这应该可以。

相关问题