basically, im having a little bit of coding trouble. i got to read the data from a user chosen file and then output it into an array for an algorithm to sort. the problem is that the 4 test files have different amounts of integers in, so i dont know what the initial size of the array is going to be. and it comes up with a null pointer error on runtime if i dont state the size of the array! the code itself has no syntax errors. any help appreciated. my code is listed below:
You are putting the contents into the array several times; you only need to do it once. You are also declaring the array inside the for, so it is a local variable which goes out of scope at the end of the block. You must be shadowing a field of the same name, which you are never gaining access to from the "for".
Joined: Sep 19, 2008
you do not need loop statement to convert arraylist into array
Use for loop to add data into the arraylist.
Then outside for loop use something like this.
You will be all set.
Joined: Nov 05, 2009
cheers guys! problem solved!! just got to implement the sorting algorithms now and its done. thanks for your help x
Joined: Oct 13, 2005
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com