I need to convert a set of ArrayLists of n length to a JTable.
ArrayList<Double> operand1 = new ArrayList<>();
ArrayList<Double> operand2 = new ArrayList<>();
ArrayList<Double> userAnswer = new ArrayList<>();
ArrayList<Double> correctAnswer = new ArrayList<>();
Each of these Arraylists will be the same length.
I'm having some trouble converting them into a multidimensional array where I can eventually use that array in a JTable.
I have tried a number of things.
// converting the single list to an array: error obj to double
Double [] arr = new Double[operand1.size()];
arr = operand.toArray();
// Shot in the dark
arr = Arrays.copyOf(operand1.toString(), operand1.size(), Double.class);
The goal would be to....
// Needs a name for each column
Double [][] data = {operand1, operand2, userAnswer, correctAnswer}
//or individually add them via
JTable table = new Table();
table.add(operand)
Any help would be greatly appreciated. Additionally, if there is a way to make this into a method that would be awesome.