Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7090075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:00:01+00:00 2026-05-28T08:00:01+00:00

With my Tile Editor that I created I get an Array like this: int

  • 0

With my Tile Editor that I created I get an Array like this:

int [][] Level02 = new int[][]  {
                            { 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12}, 
                            { 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12}, 
                            { 11, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, 13, -1, -1, -1, -1, 12}, 
                            { 11, 13, -1, -1, 27, 27, 27, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, 13, 13, -1, -1, -1, 13, 13, -1, -1, -1, 32, -1, -1, 27, 27, 25, 25, 27, 27, -1, -1, 32, 12}, 
                            { 16, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1, 13, 13, -1, -1, -1, 13, -1, -1, -1, 25, 25, 25, -1, -1, -1, 27, 27, 27, 27, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}, 
                            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 16, 1, 1, 1, 1, 1, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 
                            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 
                            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 
                            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 
                            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
                        }

So it prints out a 2 dimensional array.

The problem is that I have hundreds of these in one class and what to organize them to be able to do like: Levels.getlevelCount;

So I figured out that I could do a 3 dimensional Array: int [][][] AllLevels = new int [][][]

But my question is:
Are there anyway to declare an array within another sort of like this:

int[][][] all = new int[][][]{


      int [][] Level01= new int[][] {
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};

int [][] Level02= new int[][] {
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 
    { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};


        };

Above code gives a Compiling Error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:00:01+00:00Added an answer on May 28, 2026 at 8:00 am

    You can’t do exactly what you have there but you can do this.

    int [][] twod1 = {{1, 1,}, {-1, -1}};
    
    int [][] twod2 = {{1, 1,}, {-1, -1}};
    
    int [][][] threed = {twod1, twod2};
    

    Or you can do it in reverse if you prefer.

    int [][][] threed2 = {{{1, 1,}, {-1, -1}},
                         {{1, 1,}, {-1, -1}}};
    
    int [][] twod3 = threed2[0];
    
    int [][] twod4 = threed2[1];
    

    You can also do it inline, I don’t think its very readable though. If you do it inline you also can’t use short hand initialization you actually have to declare the new int[][] for each 2-dimensional int array.

    int [][] twod5; 
    
    int [][] twod6;
    
    int [][][] threed3 = { twod5 = new int[][]{{1, 1,}, {-1, -1}},
                           twod6 = new int[][]{ {1, 1,}, {-1, -1}}};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a tile/sprite editor kind of like Pixen, but I couldn't find one
hi made an object layer on my tile map with tile map editor like
I have Tile s which represent the tiles in a game's 2-dimensional world. The
I would like to tile a CGImage across a CALayer, but it seems to
I'm writing a little tile-based game, for which I'd like to support light sources.
I'm creating a 2d tile based sim game. I have a 2d array of
I'm using tiled to create a tile map. (Tiled is a tile map editor
I have a large 150px x 150px tile that has 9 smaller 50px x
Sorry if the tile is misleading. What i would like to do is to
I'm using C++ to create a tile map for a game. My problem is,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.