This is the array code I have so far:
ArrayList<Data> arrl = new ArrayList<Data>();
arrl.add("Tim", 23);
Need to know how to an integer and a string to the array.
For Example:
names: and ages: Tim 23 Max 56 Clare 43
I know how to add integers OR strings to array-lists but i can't figure how to incorporate both in the same array.
ArrayListis meant to storeDataobjects. So addDataobjects.Listinterface on the assignment variable. Like:List<Data> arrl = new ArrayList<Data>();List<Data> arrl = new ArrayList<Data>();thenarrl.add(new Data("Tim", 23)). Depending on your usage (ie if you will know the names and want to look up the ages) you could use a Map instead. If this is relevant to you I can give an example.List<Object> arrl = new ArrayList<Object>(); arrl.add("Tim"); arrl.add(new Integer(23));-- depends what the OP is after I suppose.