• Post Reply Bookmark Topic Watch Topic
  • New Topic

re:String buffer null pointer exception  RSS feed

 
vidu mayur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this program displays each character entered in the input as a seven segment digit.
For e.g, if the input is 123

The output is stored in three string buffers one for each output line. As each input digit is processed,append four characters to each buffer(three for the digit itself plus a space) For e.g., if the current digit is 9, th eprogram would append " _ " to the first buffer, " |_| " to the second buffer and " _| " to the third buffer.
I have tried the program by printing a single digit. It worked, but with multiple digits using string buffer, it gives me a null pointer exception. What am I doing wrong here?

Thanks in advance
[ December 03, 2003: Message edited by: vidu mayur ]
[Fixed overlong line in code tags - Jim]
[ December 03, 2003: Message edited by: Jim Yingst ]
 
Joe Ess
Bartender
Posts: 9443
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is polite to post the exception and stack trace. Gives those of us trying to read your code a hint as to where the problem is. In your case the problem is obvious enough. You create an array for StringBuffer objects but you don't put any StringBuffers in it. It should be getting the null pointer exception on this line:
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Vidu -
Can you make your code snipped narrower and shorter? You'll find people much more eager to help if the code is shorter and the question focused.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you make your code snipped narrower and shorter?
I fixed it. Don't put [code] tags around really long lines of text with no newlines - they don't wrap, and force the display to be really wide.
 
vidu mayur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for taking the time to read a long and wide post
When I didn't add the UBB code for the top message, it wasn't displaying my LCD numbers properly. Thanks Jim for making it narrower. Joe, that was the problem. Once I fixed it, it started working.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!