• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Bug in one of a couple methods

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 5114
38
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 28394
100
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 80613
467
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9012
655
Mac OS X Spring VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic