OK. But you already have the explanation of this NPE, and just patching the code to bypass it still won't make your program work.
If you really don't want to use split, you should have program that looks like this:
create empty string array for words.
start copying input to a temporary string until you hit a " "
put the temp string into the first/next element of word array
repeat until input exhausted.
Test, and don't try to do anything else until this works.
Create temp String "" to hold longest.
Compare length of each word against length of the temp String
if it's longer, copy word to the temp String
When all words processed, temp String contains the longest one.
Last edited by JamesCherrill; Jul 5th, 2009 at 2:17 pm.
Reputation Points: 1924
Solved Threads: 951
Posting Expert
Offline 5,788 posts
since Apr 2008