• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Good way to do it

frank100

Lurker
I am in a situation where i need to declare something like this
2000=>1,3,3,3,5,5
2001=>1,3,1,0,1,3
2002=>1,2,3,7,0,2
2003=>1,45,3,3,5,1
2004=>1,2,3,3,8,9
(I don't need any thing below 2000)

if i declare array like
arrayname[2000]="1,3,3,3,5,5";
arrayname[2001]=>1,3,1,0,1,3
won't it mean i will be wasting 1900 values.
Does it have any effect on memory or processing(.

what is best way of doing it?
hasmap ,map ,multidimensional array?

I am new to java and android development.

thanks
 
You could use a Map, but if your keys are all integers a SparseArray might be better. The best choice will depend on your application (for example you might care about insertion speed or you might just populate the structure once and read from it), but unless you have thousands of entries in the data structure it probably isn't worth worrying too much about unless performance becomes an issue.
 
Back
Top Bottom