2

Was instructed, for a university-level assignment, to receive user input through "standard input". Google was a bit scarce as to what precisely this means.

While I could (and for the sake of my grade, will) go to my professor for clarification, I figured I would ask Stack Overflow so if anyone in the future has the same question they can find this and do without the research I performed; additionally, I appreciate the history lesson some Stack Overflow contributors provide.

Basically, what I found was receiving user input was originally done via standard input methods (hardware). However, and this is where things get complicated, now the process has been abstracted. Instead of requiring hardware, now, through something called redirection/pipelining, we can modify where the input will come from.

In addition to clarifying what the above means, I, personally, am interested in a Java-specific response.

Simply put, there are three "common" ways of receiving user input in Java SO Source: BufferedReader vs Console vs Scanner

Basically, what I got from the above, is that the differences involve optimization for what you intend to do with the input and how the input is stored/treated, in terms of whether it is received as the ASCII Integer or whatever.

My question is are all three of the above methods considered standard input? Is there a way of obtaining user input NOT through standard input? By user input I mean something the user inputs manually upon program execution, not transferring data from a file or anything like that.

Furthermore, when receiving input in the above way, is it worth checking for null?

Example:

   Scanner a = new Scanner(System.in);
   String testInput = a.nextLine();
      if (testInput == null)

How can something input by the user ever point to nothing in memory (i.e. null?) is this ever possible?

Community
  • 1
  • 1
coder
  • 25
  • 6
  • Another assignment question? I've read your other questions: Stack is not here to do your homework. Besides, you will never learn if you don't try. I deleted my answer. – wellplayed Oct 24 '16 at 13:57

0 Answers0