• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Arrays

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I may sound stupid..... But can anyone help me how to find out the elements in an multi dimensional array....like

. Say if this array has been initialized they how do locate an element at say [0][1][2]...& so on & also the array length.
Thx
Aruna
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aruna,
I havent done any modifications to your array. Just go through this and find out. I have just intented your array so that it becomes self-explanatory.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have run it and do not understand why do we get those "NullPointerException"?. I thought by default we will get some "null" in the array.
 
Yamuna Pattathil
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Equating an array to null and equating an element of an array to null makes the difference as in the following code.

 
Aru Ven
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yamuna, Thank You.
Aruna
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this strategy to "visualilze" the multi-dimensional array -
With every open brace '{' start a new dimension and with every '}' seal the most recently opened dimension.
Also, while dealing with such questions, remember that Java supports sparse arrays ie., each sub-array of a multidimensional array can be of different length. To make it simple, if you imagine a two-dimensional array as a rectangle, each row in the rectangle can have different number of elements.
Just my two cents worth...
Ajith
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aru,
You don't sound stupid. You are just braver that all the souls out there who don't understand either - but are too chicken to ask!

[This message has been edited by Cindy Glass (edited December 19, 2000).]
reply
    Bookmark Topic Watch Topic
  • New Topic