Originally posted by Mishra Anshu:
br.readLine() returns the contents of a line, not including any line termination chracters or null if the end of the stream has reached.
so, when you type at the console "null", it is not the null object but it is the string "null".
The String "nul" is not a null object.
null means something that doesn't exist.
Hope it helps.
Thanks for replying.
In that case shouldn't this work
while((val = br.readLine()) != "null") {
System.out.println(val);
But it doesn't work.
Even tried with something like
while((val = br.readLine()) != "stop") {
System.out.println(val);
and then wrote "stop" on the console (without quotes), but it doesn't work.