Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I import the data in my array list to a JTable?
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/12880722/is-there-any-way-by-which-i-can-create-a-jtable-using-the-data-in-an-arraylist">Is there any way by which I can create a JTable using the data in an ArrayList?</a> </p> </blockquote> <p>The code of my program is as follows:</p> <pre><code>//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&lt;double[]&gt; l = new ArrayList&lt;double[]&gt;(); 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&lt;=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)); } } } </code></pre> <p>How do I import the values in the rows to create a table? It becomes difficult to import the values.</p> <p>The output is somewhat like :</p> <p>[1.0, 1342.05, 1040.0, 302.04999999999995, 249697.95]<p> [2.0, 1342.05, 1038.7434719999999, 303.30652800000007, 249394.64347200003]<p> [3.0, 1342.05, 1037.48171684352, 304.56828315648, 249090.07518884353]<p> [4.0, 1342.05, 1036.214712785589, 305.835287214411, 248784.23990162913]<p> [5.0, 1342.05, 1034.942437990777, 307.1075620092229, 248477.13233961992]<p> [6.0, 1342.05, 1033.6648705328187, 308.3851294671813, 248168.74721015274]<p> [7.0, 1342.05, 1032.3819883942353, 309.6680116057646, 247859.07919854697]<p> [8.0, 1342.05, 1031.0937694659553, 310.9562305340446, 247548.12296801293]<p> [9.0, 1342.05, 1029.8001915469338, 312.2498084530662, 247235.87315955988]<p> [10.0, 1342.05, 1028.501232343769, 313.5487676562309, 246922.32439190365]<p></p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload