Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

initializing an array

 
Bron Czimes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i'm trying to put some items into an array based on the outcome of an if statement. I keep getting an error that says i haven't initialized my array properly or something. I'm not sure how to initialize an array if you don't want to put values in straight away, but a bit later on.
Anyway, the code is



Can anyone help?
Bron

Carl - Edited Code to fit on screen
[ June 04, 2004: Message edited by: Carl Trusiak ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the Exact Exception message you are getting? Is it an exception during run time or compile? I don't see anything that should be a compile error but, You WILL get an ArrayIndexOutOfBoundsException on the two code lines:

Arrays are Zero based!!! so, the indexes are from 0 - 19

This should be:
 
Bron Czimes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aha!
Thankyou.
I do know that arrays are zero-based, but I had changed it for anther part of my program and had forgotten to put it back.
Thankyou for picking up on my absent mindedness

Bron
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic