getting nullpoint exception again

Reply

Join Date: Jun 2009
Posts: 99
Reputation: akulkarni is an unknown quantity at this point 
Solved Threads: 4
akulkarni akulkarni is offline Offline
Junior Poster in Training

Re: getting nullpoint exception again

 
0
  #11
Jul 5th, 2009
  1.  
  2. i am sorry
  3.  
  4. i wanted to do it in my way. I know and remember other posts.But if you could solve the NPE problem in one case u could do it in other as well. I know the split or String tokenizer method. (i am tryng to explain for loop to one of my friends so i just took a chance if u could solve it.But its ok.
  5. sorry again .
  6.  
  7. thanks
  8. akulkarni
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 964
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 143
JamesCherrill JamesCherrill is offline Offline
Posting Shark

Re: getting nullpoint exception again

 
0
  #12
Jul 5th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC