programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

# Multi-dimensional array

Ranch Hand
Posts: 78
• Number of slices to send:
Optional 'thank-you' note:
Hi,

Given:
12. float f[ ][ ][ ] = new float[3][][];
13. float f0 = 1.0f;
14. float[ ][ ] farray = new float[1][1];

Which is valid?
A. f[0] = f0;
B. f[0] = farray;
C. f[0] = farray[0];
D. f[0] = farray[0][0];

Regards,
Seema

Ranch Hand
Posts: 169
• Number of slices to send:
Optional 'thank-you' note:

B chicce is correct because f[0] refers to a 2dimensional floating array and since farray is 2dimensional so f[0] = farray.

to help you to understand better let me make a change in array f..

now:
f[0] refers to 2dimensional float array.
f[0][0] refers to a 1dimensional float array and
f[0][0][0] stores a floating point value !!

hope this explanantion helps!!
[ July 25, 2007: Message edited by: Priyam Srivastava ]

Seema Sharma
Ranch Hand
Posts: 78
• Number of slices to send:
Optional 'thank-you' note:
Priyam,
Can you explain me this with small example. I still have a doubt how:

f[0] refers to 2dimensional float array.
f[0][0] refers to a 1dimensional float array and
f[0][0][0] stores a floating point value

Regards,
Seema

Priyam Srivastava
Ranch Hand
Posts: 169
• Number of slices to send:
Optional 'thank-you' note:

can you tell exactly what your confusion is, as it might help you to give a better example..
thanks!
[ July 25, 2007: Message edited by: Priyam Srivastava ]

Greenhorn
Posts: 15
• Number of slices to send:
Optional 'thank-you' note:
Hi Seema,

I've prepared a short example:

Cheers,
Robert
[ July 25, 2007: Message edited by: Robert Horvath ]

Seema Sharma
Ranch Hand
Posts: 78
• Number of slices to send:
Optional 'thank-you' note:
Thanks Priyam and Robert for your explanations.

 Do not set lab on fire. Or this tiny ad: the value of filler advertising in 2021 https://coderanch.com/t/730886/filler-advertising