File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes initializing an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "initializing an array" Watch "initializing an array" New topic
Author

initializing an array

Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
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

Joined: Jun 13, 2000
Posts: 3340
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:


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Bron Czimes
Ranch Hand

Joined: May 09, 2004
Posts: 44
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: initializing an array