# 4 dimensional array decleration

• 11-17-2013, 12:49 PM
bodylojohn
4 dimensional array decleration
Hello everybody..

My name is John and I have decided to learn java.

I am fiddling around a bit with it and I want to make declare a 4dimensional int array where EACH array containing 20 cells.

I have this:
Code:

`int[][][][] vierdeDimensie = new int[20][20][20][20];`
Is this correct?

• 11-17-2013, 01:07 PM
JosAH
Re: 4 dimensional array decleration
Yep, it' fine; do realize that the array contains 20*20*20*20 elements (160000).

kind regards,

Jos
• 11-17-2013, 01:10 PM
bodylojohn
Re: 4 dimensional array decleration
Quote:

Originally Posted by JosAH
Yep, it' fine; do realize that the array contains 20*20*20*20 elements (160000).

kind regards,

Jos

Thank you very much.

This is a practice exercise I am doing and the exercise literally says:
Declare a 4dimensional int array where EACH array containing 20 cells.
• 11-17-2013, 01:43 PM
JosAH
Re: 4 dimensional array decleration
Quote:

Originally Posted by bodylojohn
Thank you very much.

This is a practice exercise I am doing and the exercise literally says:
Declare a 4dimensional int array where EACH array containing 20 cells.

If that's what the exercise says ... you have memory enough for that 4D matrix (160000 elements times 4 bytes per element makes 640000 bytes of memory; we wouldn't dream of that much memory in the 70s of the previous century ;-)

kind regards,

Jos
• 11-17-2013, 01:49 PM
bodylojohn
Re: 4 dimensional array decleration
Quote:

Originally Posted by JosAH
If that's what the exercise says ... you have memory enough for that 4D matrix (160000 elements times 4 bytes per element makes 640000 bytes of memory; we wouldn't dream of that much memory in the 70s of the previous century ;-)

kind regards,

Jos