Having this:
static class Girl{
public String age;
public String name;
public String id;
}
static Girl[] girl;
Then i am unable to do this in my main function:
ResultSet r = s.executeQuery("select count(*) from children");
r.next();
girl_count=r.getInt(1);
girl = new Girl[girl_count];
r = s.executeQuery("select * from children");
int i = 0;
while(r.next()){
i = r.getString("id");
if(girl[i]==null)girl[i]=new Girl();
girl[i].age=r.getString("age");
girl[i].name=r.getString("name");
girl[i].id=r.getString("id");
}
The above code is not working, what i would like to acheive is:
System.out.println(girl[3]);
especially this line:
girl = new Girl[girl_count];
Can anyone help me correct this code ? - or find out what i'm missing here?