I am following Prinston's course Algorithms, Part I
. As I came from .NET
and just started to use Java
, I have some issue with a piece of Java
code and I can not find any related information. They provide with a code which I can use for reading a text file:
public static void main(String[] args) {
In in = new In(args[0]);
int n = in.readInt();
...
}
Exception thrown:
In cannot be resolved to a type
What is this In
? Should I import some package or what should I do?
The whole code and description can be also seen here: http://coursera.cs.princeton.edu/algs4/assignments/collinear.html
You need algs4, provided by Princeton as well. When it's in the classpath, add
import edu.princeton.cs.algs4.In;
If that's the only class, you could use the source of In.java. But I doubt that's allowed on Coursera: when you submit code, it will probably be compiled on the server with algs4.jar in the classpath, so you should really use that one and not your own code.