Hi, I have a situation where user can input the name of the files through html form (1 or 2 file, max is 2 files). Is it better to hold the file names in an array or in a vector? The problem is if i store it in an array, as the size of the array is 2. The element at location 2 in the array is null, which is leading to nullpointerexception when user submits only 1 file name. So, i am using vector instead of array to avoid this exception. Is this ok to do? If not, what's is the efficient way to do? Appreciate your input. Thanks,
Roy Ben Ami
Joined: Jan 13, 2002
sure , no problem... but maybe consider using ArrayList which is better than Vector.
Joined: Jun 26, 2001
Thanks for your input!
Joined: Jul 11, 2001
Originally posted by Mandy Smith: The problem is if i store it in an array, as the size of the array is 2. The element at location 2 in the array is null, which is leading to nullpointerexception when user submits only 1 file name. So, i am using vector instead of array to avoid this exception.
Why don't you instantiate an array of the correct size (1 or 2 depending on the number of entered file names? Can you post some code?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jun 18, 2002
As such u should not have any problem in using the arrays if the no. of elements are fixed. u shuld remember that array indexes starts from zero instead of 1 , so if u have used a array with the limit two say Array a; and latter u trying to access a element this will trey to acces the third element and thus will generate e exeption ArrayOutOfBoundsEexception,but in ur case it is null pointer esception so might be ur not able to put the data in the array b4 using it