java - Uses of Multi-Dimensional Arrays -


well beginning learn java have android app develop , have come across topic of multi-dimensional arrays. have noticed use draw simple tables. there other use , necessary topic future.

-k.b

there several "real life usages" of multi-dimension arrays. let me use images explain:

a greyscale image of 4x4 pixels can represented this:

int[][] myarray = {  {236, 189, 189,   0},                      {236,  80, 189, 189},                      {236,   0, 189,  80},                      {236, 189, 189,  80}  }; 

it give output, if parsed image:

grid

however, if wanted actual colors instead of greyscales, have define set of rgb or cmyk values every single pixel. in other words, need array of values each pixel. , there have example of 3 dimensional array.

this short examples should give little more insight of possible uses of multi-dimensional arrays, bear in mind usage areas countless, complete, or attempted thourough coverage of subject, pretty impossible.

you ask "is necessary topic future." use arrays directly @ in day day coding. use lot of different collections, builds upon array architecture. also, understanding of multi-dimensional arrays helps me build collections of multi-dimensional objects (objects containing other objects, containing more objects etc.) reccommend learning collections.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -