How to achieve this through vector

I am having a Vector which is having Data like[a,b,c,d,ef,g,aa,bb]. I want to display it like

abcd

ef g aa bb

I am doing this way

int size=v.size();

String s[]=new String[size];

v.toArray(s)

<%for(int i=0;i<size;i=i+4){

<td width="5%"><input type="checkbox" name="chk" value="<%=s[i]%>"></td>

<td width="5%" align="left" class='textfield' class='labelTohma'><%=s[i+1]%></td>

<td width="25%" align="left" class='textfield' class='labelTohma'><%=s[i+3]%></td>

%>

[1082 byte] By [rajpuniaa] at [2007-10-2 21:19:09]
# 1

If I understand correctly, you want the elements of vector v to be displayed in rows with columnCount columns:

<table>

<tbody>

<%

Enumeration e = v.elements();

int rowCount = (int)Math.ceil(v.size() / columnCount);

for(int row = 0; row < rowCount; row++) {

%>

<tr>

<%

for(int col = 0; col < columnCount; col++) {

if(e.hasMoreElements()) {

%>

<td><%= e.nextElement() %></td>

<%

}

}

%>

</tr>

<%

}

%>

</tbody>

</table>

jsweetlanda at 2007-7-14 0:28:18 > top of Java-index,Core,Core APIs...
# 2
A small correction to the code, replace the following two in the abovecode in order to acheive the correct "rowCount".double size = v.size();int rowCount = (int) Math.ceil(size / columnCount);
nageshvsa at 2007-7-14 0:28:18 > top of Java-index,Core,Core APIs...