Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

printOut help  RSS feed

 
xiao sean
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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.
 
Frank Bacher
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!