|Access||Adobe photoshop||Algoritmi||Autocad||Baze de date||C||C sharp|
|Calculatoare||Corel draw||Dot net||Excel||Fox pro||Frontpage||Hardware|
|Php||Power point||Retele calculatoare||Sql||Tutorials||Webdesign||Windows|
|Asp||Autocad||C||Dot net||Excel||Fox pro||Html||Java|
Java allows you to easily create multidimensional arrays:
The code used for printing uses length so that it doesnít depend on fixed array sizes.
The first example shows a multidimensional array of primitives. You delimit each vector in the array with curly braces:
Each set of square brackets moves you into the next level of the array.
The second example shows a three-dimensional array allocated with new. Here, the whole array is allocated at once:
But the third example shows that each vector in the arrays that make up the matrix can be of any length:
The first new creates an array with a random-length first element and the rest undetermined. The second new inside the for loop fills out the elements but leaves the third index undetermined until you hit the third new.
You will see from the output that array values are automatically initialized to zero if you donít give them an explicit initialization value.
You can deal with arrays of non-primitive objects in a similar fashion, which is shown in the fourth example, demonstrating the ability to collect many new expressions with curly braces:
The fifth example shows how an array of non-primitive objects can be built up piece by piece:
The i*j is just to put an interesting value into the Integer.
Politica de confidentialitate|
Adauga cod HTML in site