java - Accessing an ArrayList of another class -
java - Accessing an ArrayList of another class -
this question has reply here:
accessing instance of variable class in java 3 answersok guys, may've been posted , asked before, it's hard explain in few words, it's hard hell search well!
what want this, first class:
public class footballer { int goals; string surname= ""; string team=""; private static int counter=0; private int dres; }
(this header of class, give thought of how looks)...
and second class, contains arraylist of first class:
public class footballteam{ string teamname=""; string league=""; arraylist<footballer> f; }
and third class contains arraylist of sec clas:
public class footballleague{ string leaguename=""; arraylist<footballteam> ft; }
what want is, know how many of footballers there in league? meaning how many of "f"s in "ft"... remember c++ easy, did this: ft.f[i]; (where position), you'd go through each of them, if wanted them, or inquire it's length, if needed know how much footballers there.
i hope clear enough, please inquire me if don't i'm asking..
it's easy in java,
int counter = 0; for(footballteam team : ft) counter += team.f.size();
java arraylist
Comments
Post a Comment