Scope and try block
I'm performing some operations that returns an array that I have to use later in the loop. So, basically I have this:
try
{
Array[] tempArray = tp.getArray();
}
Outside of the block, I want to use that array, but how do I get it out? My question may just be: How do I initialize an array without defining it's size?
[439 byte] By [
subnetrxa] at [2007-10-3 2:43:40]

You need this:
Array[] tempArray;
try
{
tempArray = tp.getArray();
}
If you get an error "tempArray may not be initialized", do this:
Array[] tempArray = null;
MLRona at 2007-7-14 20:32:03 >

> ahh, ok, I just didn't understand the array concept
> then. I thought that you had to set the length at
> initialization. Thanks.
Indeed you do need to set the length at initialization. You just have initialization confused with declaration. Declaration is where you declare a variable:Array[] tempArray;
And initialization is where you create an object and (optionally) assign it to a variable:tempArray = new Array[137];