Why is StdIn.java Not Working in My Program?

  • Context: Java 
  • Thread starter Thread starter Hiche
  • Start date Start date
  • Tags Tags
    Program
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 12K views
Hiche
Messages
82
Reaction score
0
I want to use StdIn and StdOut in my program as instructed. Our teacher told us to put the StdIn.java file inside the same folder as the source file (the program I am writing). But that is not working. Always gives me an error when I use the commands.

Am I doing it wrong? Is there another way?

Code:
StdOut.print or StdIn.readIn()
(for example)
 
Physics news on Phys.org
I think you might be missing an import statement at the top of your code. It would look like this:
Code:
import StdIn;
// any other imports
.
.
.
<your code>
 
I added the import statement but the error keeps appearing: "StdIn cannot be resolved". I'm positive that I placed the StdIn.java file in the same directory as my program. I am using Eclipse as an IDE so the .java files are usually in a folder called src, where I also put the StdIn.java.
 
Never mind. I just had to refresh my project. The import statement is not really needed when we place the .java files in the same directory.