-1

I am learn Algorithms, 4th Edition with IntelliJ IDEA, however, I encouted a issue that the IDEA told me "Cannot resolve symbol 'StdIn' and 'StdOut'".

Pic: [Cannot resolve symbol "StdIn"](http: //i.imgur.com/ZRD6o53.jpg)

My project structure is correct and I set stdlib.jar as one of the dependencies, where there are StdIn and StdOut. Even I clicked "Invaildate caches and restart" the issue remains.

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

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

You may learn the details of stdlib.jar from here and 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);
    }
}
hedgehog0
  • 64
  • 1
  • 10

2 Answers2

0

I usually see this when I do not define a variable and try to use it, like here:

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;
    }
}
almeynman
  • 7,088
  • 3
  • 23
  • 37
0

This happens because the stdlib.jar does not define package structure for its classes :(

Try creating your class on default package and that should work.

Pavan Kumar
  • 4,182
  • 1
  • 30
  • 45