• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

printOut help

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i got a problem which i'm unable to solve. my program generate the desire output i wants but it also generate an error which i dont understand too. appriecate any help on this. thanks .
this are part of the esstential program codes



error generate :
java.lang.NullPointerException
at Tester.main(Tester.java:16)


[ October 20, 2007: Message edited by: xiao sean ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The loop runs form 0 to 3, but testClock[3] is null. Hence the NullPointerException when you try to dereference it.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf already stated the problem.
There are many possible solutions for your problem. One is to make the Array sized as you need it. Another ist to comment in (and correct the line
testClock[3]=new Clock(108,"IMC","8"); . You could also do a check if the array at position [i] is not null and only if that is the case execute the "getPrice()-getModel()"-line.
reply
    Bookmark Topic Watch Topic
  • New Topic