How do I implement the following data ?
somelisttype <int>obj ;
obj 0,0 => val0
obj 0,1 => val1
obj 0,2 => val2
obj 1,0 => val8
obj 2,0 => val9
obj 2,1 => val10
0,0 ; 0,1 are the keys ( or in other way the row index or column index.)
I would like to have following functionality ..
obj 0.add(val11) == obj 0,3 => val11
obj 3.add(val12) == obj 3,0 => val12
obj 2.length => 2
obj 3.length => 1
obj 0,2 => val2
ValXX => are values and not objects ( would be integers )
I don’t want to create 2d array since I don’t know length of total obj or individual obj0,obj1
What variable type can be used for this in android ??
What’s about
List<List<Integer>>?You can’t avoid the generic type to be an object here but since cast from
Integertointis implicit you would see any difference in use.Update
Okay here it is:
Here the implementation (o course you have to make sure that used index is right, so you can’t add index 1 when 0 is not already set):