Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

StdIn.java use in program

  1. Nov 10, 2011 #1
    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 (Text):
    StdOut.print or StdIn.readIn()
    (for example)
     
  2. jcsd
  3. Nov 10, 2011 #2

    Mark44

    Staff: Mentor

    I think you might be missing an import statement at the top of your code. It would look like this:
    Code (Text):

    import StdIn;
    // any other imports
    .
    .
    .
    <your code>
     
  4. Nov 10, 2011 #3
    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.
     
  5. Nov 10, 2011 #4
    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook