How can I create a 3 column table in HTML from an ArrayList?
My current code looks like this:
<table border="0">
<%
for (int i = 1; i < states.size(); i++) {
%>
<TR>
<%
for (int col = 1; col <= 3; col++) {
%>
<TD>
<%
out.println(states.get(i));}
%>
</TD>
</TR>
<%
}
%>
</table>
I get a 3 column format table but 3x the same entry in each row…

Expected output
Albania | Algeria | American Samoa
Andorra | Angola | Anguilla
..
What am I missing?
If I understand the requirement correctly (not sure that is the case), then something like this will give you a start.
It will produce output something along these lines..
Note that it still has problems. If there are ‘multiples of 3’ countries, there will be an entirely empty line at the end of the table. If not, the last row will not have the correct number of columns. BNI.