naming an array depending on input
Is there anyway of naming arrays depending on the input?
If I have an array say
String bigArray [ ] = new String[ 100 ] ;
I want to create number of temporary arrays as temp_1 to temp_10 of length 10 each, how can I do that? I know ten in this case, but what if that number is not known and is dependent on some other application?
My question is how can i create temp_1 to temp_n arrays ?
I had a similar problem a few months ago with an application I was developing. The solution to the problem was that the method I was trying to use (that you seem to be trying to use also) was not a very good method to use. In fact, I was so lost that I was referred to as being "crazy bananas" here on the forums.
So, perhaps you should try explaining exactly why you think you need a large number of temporary arrays?
Have you looked at ArrayList<String>?
Message was edited by:
Djaunl
The application (already built in VB) takes a big file about 1GB, it then chops that file (number given by the user). Then some order is defined to recombine those chunked files, and is feeded to some exe file to do some analysis.
I am trying to get rid of those intermediate temp files, and instead am trying to use temp arrays. In case of files, it is straight forward to name a file as:
temp_ & "i"
However in case of arrays in java, I can't simply append some varialbe value as "i" with the array name "temp_"
Is there is any other way accomplishing this? I really want to use arrays, because for other modules it would be very easy to code.
Rather than creating temp arrays, use a List: http://java.sun.com/javase/6/docs/api/index.html?java/util/List.htmlYou can add your elements to a list wherever you want, and you can later clear the list to free up space, etc.
DrLaszloJamf ! "embarrassed", never thought of "MEMORY". It would be silly of me to use arrays for holding that much amount of memory.I would rather go for temp files then.Thanks a lot Dr, for pointing that out.
> DrLaszloJamf !
> "embarrassed", never thought of "MEMORY". It would be
> silly of me to use arrays for holding that much
> amount of memory.
> I would rather go for temp files then.
> Thanks a lot Dr, for pointing that out.
A "wtf" bubble popped into my head when I read that 1GB thing, but I pretended it didn't exist either. Unlike DrLaszlo however, I wasn't smart enough to sneakily point it out :-(
> The application (already built in VB) takes a big
> file about 1GB, it then chops that file (number given
> by the user). Then some order is defined to recombine
> those chunked files, and is feeded to some exe file
> to do some analysis.
Not going anywhere for awhile?