Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

nullpointer exception

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when i do SWING programs i am getting nullpointer exception.what should i do?
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's really not possible to tell why there is such an error unless an until we have that part of the programme can u be a little more specific by sharing that part of the programme.

regards
 
author
Posts: 23919
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or even better... give us the exact null pointer exception message. The NPE message is very good at targeting the class, method, file, and line number where the error occured.

Henry
[ April 30, 2006: Message edited by: Henry Wong ]
 
Marshal
Posts: 75702
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have had this question before; the NullPointerException is one of the commonest. Look at this thread from the end of last year.
See whether it is of any help. There are several suggestions as to how to deal with such Exceptions. But what you ought not to be doing with most of at least these three Exceptions
  • NullPointerException
  • ArithmeticException
  • XYZIndexOutOfBoundsException
  • is to catch them, because they usually represent errors in the program somewhere.
    No, you need to find out where they are occurring and prevent them.

    NullPointerException means you have unintentionally forgotten to instantiate one of the objects, or (occasionally) have managed to destroy it without noticing.

    ...OutOfBoundsException means you haven't counted an array or String or something correctly and you are looking for a non-existent member.

    ArithmeticException usually means you are trying to divide or "%" by zero.

    If you ever have a method which deals with thoses situations and intentionally throws such an Exception, make sure you have a javadoc like thisCR
     
    To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic