Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bug in one of a couple methods  RSS feed

 
Henri Frelin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I try to append using these methods I get a null pointer error and they all work perfect individually but when called with this code, I need to comment out one of the b1 appends for it to compile, please look at my methods and let me know where I went wrong.

code calling methods...


methods... Link removed

Thank you SO MUCH in advance
 
Norm Radder
Rancher
Posts: 2240
28
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a null pointer error

Where does that happen and what variable has the null value? Backtrack in the code to see why that variable has a null value.

Please edit your post and wrap the code in code tags.
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Henri!

I added the code tags to your post, because I don't think you can edit it after somebody has replied. It would be appreciated if you could post code that way in the future, it's so much easier to read.

As for your exception, you should really look in the stack trace to see where the exception is thrown. That's the first thing you should do. If you don't get anywhere with that, then start by posting the stack trace here and people will surely help explain it to you. And as for the link you posted... a lot of people, including me, aren't going to follow a link to a site where anybody can post anything at all. If you know what I mean. Yes, just dumping a thousand lines of code on the forum isn't right either, but hopefully the stack trace will show you which method has the problem.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with NPEs is that they can occur a long way from the error producing them. If you fail to initialise a field in the constructor in line 12 the NPE can occur in the calculate method in line 297.

I am going to delete the pastebin link from the original post.
 
Henri Frelin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for responding, the issue was a node intersection of the append (MyStringBuilder Type). It was due in a couple of hours and I didn't provide sufficient material or clear enough details, so my apologies.
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henri Frelin wrote:Thank you all for responding, the issue was a node intersection of the append (MyStringBuilder Type). It was due in a couple of hours and I didn't provide sufficient material or clear enough details, so my apologies.
Don't worry, all good. One suggestion for your future assignments.

Start them as early as you can. At least read the requirements, even tho if you're not planning to sit down by it within the week of time or so. Sometimes you can assume assignment going to be easy enough, but suddenly it turns out it is not. Planning it is important part too - you'll need that in your job too, as there always will be the deadlines which needs to be satisfied.

For my assignments I always used to try to finish them at least one week prior the deadlines, so the last week i could have for refactoring and nitpicking my own code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!