• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dimension in array

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear sir what is the maximum number of Dimension an array can acept in java or any other programing language

Ans a.266 b.255 c.256 d.250

with regard

Arun kumar maalik
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Java, 1.

You can have arrays in Java, but you can't have multi-dimensional arrays. What appears to be a 2-directional array is not that; it is actually a 1-dimensional array of 1-dimensional arrays.
What appears to be a 3-dimensional array is not that, it is a 1-dimensional array of 1-dimensional arrays of 1-dimenisonal arrays.

That means you can write
and myArray[2] or myJaggedArray[2] then act as ordinary int[] arrays.

The answer to the question you meant to ask and didn't is (if I remember correctly) 255 in Java.

Other languages-don't know.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
The answer to the question you meant to ask and didn't is (if I remember correctly) 255 in Java.



??

Perhaps you could tell us what the quetstion he meant to ask and didn't is, because I'm not sure what you're trying to answer here. I'm not aware of any size restriction that limits the number of elements in an array to 255, nor can I figure out any reason why you could not have a tree of greater depth than 255 made with arrays. Did I miss something here?

My answer to the original question would be this: You can have as many dimensions in an array as you like, and as many indices in each dimension as you would like, provided your system has the memory available for it.

- Adam
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I actually tried creating an array with a large number of dimensions, my Eclipse compiler produced this message:

Too many array dimensions. Maximum is 255.

 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think this is specified in the JLS (though it should be), but it's in the JVMS: "The number of dimensions in an array is limited to 255 by the size of the dimensions opcode of the multianewarray instruction and by the constraints imposed on the multianewarray, anewarray, and newarray instructions by �4.8.2."
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any other test questions you'd like us to fill in or are you just going to Christmas tree the rest?
reply
    Bookmark Topic Watch Topic
  • New Topic