Possible Duplicate:
Is there any way by which I can create a JTable using the data in an ArrayList?
The code of my program is as follows:
//A loan Amortization example
public class LoanTable
{
public static void main(String[] args)
{
double p,n,r,a,rb,ia,pa,pno=1;
//creating a double arraylist
List<double[]> l = new ArrayList<double[]>();
p=250000;
n=360;
r=0.416/100;
a=1342.05;
rb=p;
//calculating the amount as interest, amount as principal and remaining balance
for(int i=1; i<=n;i++)
{
ia=(rb*r);
pa=a-ia;
rb=rb-pa;
l.add(new double[] { pno,a,ia,pa,rb });
pno++;
}
for (double[] row : l)
{
System.out.println(Arrays.toString(row));
}
}
}
How do I import the values in the rows to create a table? It becomes difficult to import the values.
The output is somewhat like :
[1.0, 1342.05, 1040.0, 302.04999999999995, 249697.95]
[2.0, 1342.05, 1038.7434719999999, 303.30652800000007, 249394.64347200003]
[3.0, 1342.05, 1037.48171684352, 304.56828315648, 249090.07518884353]
[4.0, 1342.05, 1036.214712785589, 305.835287214411, 248784.23990162913]
[5.0, 1342.05, 1034.942437990777, 307.1075620092229, 248477.13233961992]
[6.0, 1342.05, 1033.6648705328187, 308.3851294671813, 248168.74721015274]
[7.0, 1342.05, 1032.3819883942353, 309.6680116057646, 247859.07919854697]
[8.0, 1342.05, 1031.0937694659553, 310.9562305340446, 247548.12296801293]
[9.0, 1342.05, 1029.8001915469338, 312.2498084530662, 247235.87315955988]
[10.0, 1342.05, 1028.501232343769, 313.5487676562309, 246922.32439190365]
Thanks.