Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualdmatter

Posted 15 August 2012 - 03:05 PM

Hope this works Posted Image

Almost, the line variable is null so you can't invoke .equals without causing an NPE. You could choose to initialise the string to something other than the termination condition. Another way to go is to reverse the equality operands since equals() can correctly cope with null as a parameter, e.g.

while(!"-END_OF_STREAM-".equals(line))

#1dmatter

Posted 15 August 2012 - 03:04 PM

Hope this works Posted Image

Almost, the line variable is null so you can't invoke .equals without causing an NPE. You could choose to initialise the string to something other than the termination condition. Another way to do go is to reverse the equality check to cope with null, e.g.

while(!"-END_OF_STREAM-".equals(line))

PARTNERS