Input and Output

if you want to input something in Java, you should add import java.io.*; before your class name, throws IOException after (String args[]), and DataInputStream for buffering


Try this:
import java.io.*;
public class import
{
   public static void main (String args[]) throws IOException
    {
      DataInputStream newinput = new DataInputStream(System.in);
      String new;
      System.out.println("Enter phrase here:");
      new = newinput.readLine();
      System.out.println(new);
     }
}


Note that newinput can be replaced by any word or letter which depends to the programmer. Let's say that the programmer wants to put his name on it, let's say his name is Nick, Nick can put it this way...

      DataInputStream Nick = new DataInputStream(System.in);
      String new;
      System.out.println("Enter phrase here:");
      new = Nick.readLine();
      System.out.println(new);
     }
}


Make sure also, that the uses of newinput in the program are replaced by Nick.


Notice: readLine should always be written as readLine() with an uppercased L.

No comments:

Post a Comment

Extended Search

Custom Search
Hello World