Suppose I collect n number of rows into an array or list of arrays or some other data structure. I want to come up with a design that will allow the user to determine how to sort the lines:
- If the user specifies parameter A, the lines will be placed in the vector, and then sorted and printed.
-If the user specifies option B, the lines will be placed in the list, and then sorted and printed.
I want my design to be flexible enough so that I can easily add additional sorting methods in the future (and my sorting methods).
My current implementation involves collecting rows from a user in an ArrayList, and then depending on the sorting method I will use Collections.copy (array, vector) or Collections.copy (array, list). Then I will do Collections.sort (vector or list).
(I am currently getting NullPointerExceptions on Collections.copy) ...
I'm not sure I'm going to do this in the best, most convenient way to use. Any thoughts?
Thank!
source
share