Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Trying to understand what boolean[][][] is

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trying to understand what boolean[][][] is

    As the title says I'm trying to figure out how boolean[][][] works. I've got some code i was trying to understand, but I've never seen this before as I've only been doing java for a month.
    Here is a snippet of the code I'm trying to figure out.
         int goal;
         boolean[][][] computed;
         double[][][] p;
         boolean[][][] roll;
         computed = new boolean[goal][goal][goal];
         if (computed[i][j][k]) return p[i][j][k];
    Last edited by JB4times4; August 29th, 2011 at 04:56 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Trying to understand what boolean[][][] is


  3. #3
    Super Moderator Sean4u's Avatar
    Join Date
    Jul 2011
    Location
    Tavistock, UK
    Posts
    637
    Thanks
    5
    Thanked 103 Times in 93 Posts

    Default Re: Trying to understand what boolean[][][] is

    An old version of something I wrote once implemented a 3D grid laid out in layers, rows and columns. At each point in the grid a value was either true or false, and I used boolean[][][] to represent it. To get or set the value of a point in the 3D grid, I once coded this:
    boolean[][][] example;
    // set a single point (2, 1, 4) in the 3D space
    example[2][1][4] = false;
    Watch out for nested arrays in Java (it doesn't have multidimensional arrays) - your example may look like a cuboid 3D space, but in Java boolean[][][] is an array of arrays of boolean arrays. Each individual array can have a different length.

Similar Threads

  1. I don't understand what I'm supposed to do
    By dmcettrick in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 11th, 2011, 09:34 AM
  2. I dont understand why this happens....
    By ashenwolf in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 10th, 2011, 09:31 PM
  3. Can't understand why Interfaces are there
    By vortexnl in forum Object Oriented Programming
    Replies: 9
    Last Post: February 14th, 2011, 01:06 PM
  4. 2 errors I can't understand
    By Brock in forum What's Wrong With My Code?
    Replies: 8
    Last Post: December 27th, 2010, 12:56 AM
  5. Boolean method returning a boolean value
    By Deprogrammer in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 10:56 AM