Java multidimensional array for android app -
i doing app have many exercises (for working out) each contain 5 different strings. linked workouts arrays of exercises (but more 1 workout can have same exercise , don't want waste memory), , workouts displayed in different categories (weight loss, body building, etc..).
if doing in c (which language program in) have exercises array of structure called exercise, workout linked lists each link being pointer exercise, int reps , int sets. , workouts organized in array of pointer pointing first element of linked list (so workout can in multiple categories). there way implement in java?
working backwards method in c, why not have like:
class exercise { private string exname; private int reps; private int sets;
and making constructor:
public exercise(string newname, int newreps, int newsets) { exname = newname; reps = newreps; sets = newseats;
that's part different c.
here, you're doing making exercise object contains necessary information, reps , sets.
the constructor makes new instance of object.
then can use regular arraylist list of exercises , list of workouts.
so end can visualize like:
[[exercise1, exercise2, ...][exercise1, exercise2, ....]...]
so outermost list arraylist of workouts, inner list arraylist of exercises each workout, , each exercise structure contains (optional) name, along list of reps , sets.
Comments
Post a Comment