开发者

Initializing an 2D array when I don't know the sizes

I have a 2D array of bitmaps.

Bitmap[][] b;

I know how many members the 1st dimension has, but I don't know how many members any of the 2nd dimensions have. For example it might be:

b[0] = [x,x]   //2 bitmaps
b[1] = [x]     //1 bitmap
b[2] = [x,x开发者_Go百科,x] //3 bitmaps

I want to be able to set each dimension of b at a different time, but I can't seem to do anything with b until I create the object...and I can't create it if I don't know how many objects each dimension has. I'm in a catch22 here and stuck.

Is there a way to create each dimension independently at a different time?


This should be the way to do it:

Bitmap[][] b = new Bitmap[3][];
b[0] = new Bitmap[2];
b[1] = new Bitmap[1];
b[2] = new Bitmap[3];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜