Results 1 to 5 of 5
  1. #1
    bodylojohn is offline Member
    Join Date
    Nov 2013
    Posts
    37
    Rep Power
    0

    Default 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:
    Java Code:
    int[][][][] vierdeDimensie = new int[20][20][20][20];
    Is this correct?

    Thanks in advance!!!

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: 4 dimensional array decleration

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

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    bodylojohn is offline Member
    Join Date
    Nov 2013
    Posts
    37
    Rep Power
    0

    Default Re: 4 dimensional array decleration

    Quote Originally Posted by JosAH View Post
    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.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default Re: 4 dimensional array decleration

    Quote Originally Posted by bodylojohn View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    bodylojohn is offline Member
    Join Date
    Nov 2013
    Posts
    37
    Rep Power
    0

    Default Re: 4 dimensional array decleration

    Quote Originally Posted by JosAH View Post
    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
    thanks for your trouble jos!

Similar Threads

  1. [SOLVED] Three-Dimensional Array
    By Liq in forum New To Java
    Replies: 7
    Last Post: 07-04-2013, 07:11 PM
  2. two dimensional array
    By shahnawazzzzzz in forum Java Software
    Replies: 2
    Last Post: 10-05-2011, 05:47 AM
  3. Help with Two Dimensional Array
    By johnjacob in forum New To Java
    Replies: 2
    Last Post: 06-03-2011, 09:22 PM
  4. Two dimensional array
    By niu_niu in forum New To Java
    Replies: 4
    Last Post: 06-13-2010, 01:34 AM
  5. two-dimensional array
    By kHim in forum New To Java
    Replies: 4
    Last Post: 11-16-2008, 08:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •