File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Arrays" Watch "Arrays" New topic
Author

Arrays

Aru Ven
Ranch Hand

Joined: Sep 28, 2000
Posts: 199
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
Yamuna Pattathil
Greenhorn

Joined: Dec 03, 2000
Posts: 19
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.
quan zhu
Greenhorn

Joined: Dec 14, 2000
Posts: 27
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

Joined: Dec 03, 2000
Posts: 19
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

Joined: Sep 28, 2000
Posts: 199
Yamuna, Thank You.
Aruna
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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).]


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arrays
 
Similar Threads
Queries
Anonymous Arrays
array dimension confusion
Uni JAVA Exam Monday HELP!!
Block Sliding Puzzle