hi, i just want to get some opinions on a queues homework project. i haven't written any code yet, but just want to know if it is possible to create an array[16] items and then that each item has an array[1][3], i have to work independently with each item of the first array (array[16]), so i don't know if it will be best to create an array[16][1][3] or create the array[16] that contains 16 array[1][3], thank

Recommended Answers

All 5 Replies

You can do either, but initialising a 3D array in one go can be a little daunting, depending on what your putting in.

You could just initialise all your double arrays, then do...
String[][][] array=new String[][][]{
doubleArray1,doubleArray2,doubleArray3, etc,...}

Hope that helps

thanks i ll try that

array[16][1][3] is of no practical use. Why nest the third level under a second level that only contains a single item? You are just making more work for yourself and creating potential problems by doing that.

array[16][1][3] is of no practical use. Why nest the third level under a second level that only contains a single item? You are just making more work for yourself and creating potential problems by doing that.

yeah i just realize that i m doing more work than what i was thinking, but the problem that i have is that i have 16 arrays[][] in class and i need to access them individually from an other class and the only way i can think of doing this is by using an array[][][], if anyone know a more efficient and easy way to do so, the advise will be more than welcome

First question would be: why are other classes accessing your internal arrays? That shouldn't be the case.

Second: How does having the third dimension facilitate any extra functionailty at all? It doesn't. It just adds another layer of nesting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.