I am making a method that should return a long []. It looks like this:
public long[] parseString(String input)
line input:
Inside parseString, I use a regex to get all numbers and add them to an ArrayList, since I can't know how many matches it will find.
In the end, I create long [] with the size of arrayList and do a for each to add it to long [] var.
Another way: First count each event with
while ( matcher.find() ) size++;
and then with size create a long [] of size and do: matcher.reset () and now save the long values in the variable long [].
What do you think is the best?
Is there a better way to do this?
Remember that I cannot change the method signature :(