Displays every second item off array
Code:
private void BirdActionPerformed(java.awt.event.ActionEvent evt) {
String[] tower = new String[56];
String plus = "";
for (int ry = 0 ; ry < 1 ; ry++)
{
tower [ry] = data4[ry].getId()+"\t"+data4[ry].getWetnam()+spaces(data4[ry].getWetnam())+data4[ry].getNaam()+spaces(data4[ry].getNaam());
plus = plus+tower[ry]+"\n\n";
}
textArea1.setText(plus);
}
It only displays every second item in the array. for egg:
1 Struthio camelus Ostrich
3 Gyps coprotheres Cape Vulture
5 Torgos tracheliotus Lappetfaced Vulture
7 Circaetus gallicus Blackbreasted Snake Eagle
9 Podica senegalensis African Finfoot
11 Cursorius temminckii Temminck's Courser
13 Pterocles gutturalis Yellowthroated Sandgrouse
15 Coracias caudata Lilacbreasted Roller
and it should be displaying 1-16.
Does anyone know where I have gone wrong?
Re: Displays every second item off array
Quote:
Originally Posted by
Johanis
Code:
for (int ry = 0 ; ry < 1 ; ry++)
I don't know if it matters much but this loop only runs once (for ry having the value zero).
kind regards,
Jos
Re: Displays every second item off array
Code:
int lengte = data4.length;
String[] tower = new String[lengte];
String plus = "";
int ry = 0;
for(ry = 0; ry<lengte; ry++)
{
tower [ry] = data4[ry].getId()+"\t"+data4[ry].getWetnam()+spaces(data4[ry].getWetnam())+data4[ry].getNaam()+spaces(data4[ry].getNaam());
plus = plus+tower[ry]+"\n\n";
}
textArea1.setText(plus);
Changed it to this and it works now :)