Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. initialization of 3D array in java

initialization of 3D array in java

Scheduled Pinned Locked Moved Java
javadata-structureshelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gateway23
    wrote on last edited by
    #1

    int a[][] = { {1,2}, {2,3}}; this is how we can initialize an 2d array at the time of its deceleration but i don't know how to initialize an 3d array in java at the time of its deceleration. Please help me friends.. :doh:

    L M 2 Replies Last reply
    0
    • G gateway23

      int a[][] = { {1,2}, {2,3}}; this is how we can initialize an 2d array at the time of its deceleration but i don't know how to initialize an 3d array in java at the time of its deceleration. Please help me friends.. :doh:

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      an N-dimensional array is like a one-dimensional array where each element is an N-1 dimensional array. It gets initialized by providing initialization for all its elements, comma-separated and within curly brackets. You figured it out for 2D, now do the same for 3D. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      1 Reply Last reply
      0
      • G gateway23

        int a[][] = { {1,2}, {2,3}}; this is how we can initialize an 2d array at the time of its deceleration but i don't know how to initialize an 3d array in java at the time of its deceleration. Please help me friends.. :doh:

        M Offline
        M Offline
        musefan
        wrote on last edited by
        #3

        int a[][][] = { { {1,1}, {1,2} }, { {2,1}, {2,2} } }; ...Perhaps a simple rule is the number of dimensions is equal to the number of opening curly braces at the start. Another point, are you sure you want a 3D array? what data are you storing?

        I may or may not be responsible for my own actions

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups