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 8815387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:21:51+00:00 2026-06-14T04:21:51+00:00

I have a array right now, static int[][] map = new int[WIDTH][HEIGHT]; This code

  • 0

I have a array right now,

    static int[][] map = new int[WIDTH][HEIGHT];

This code places tiles on the map:

for (int y = 18; y < HEIGHT; y++) {
        for (int x = 0; x < WIDTH; x++) {
            map[x][y] = STONE;
        }

    }

    for (int y = 18; y < 19; y++) {
        for (int x = 0; x < WIDTH; x++) {
            map[x][y] = GRASS;
        }

    }

    for (int y = 19; y < 20; y++) {
        for (int x = 0; x < WIDTH; x++) {
            map[x][y] = DIRT;
        }

    }

And here is how I render them:

for (int x = 0; x < WIDTH; x++) {
        for (int y = 0; y < HEIGHT; y++) {
            switch (map[x][y]) {
            case CLEAR:
                air.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
                break;
            case STONE:
                stone.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
                break;
            case GRASS:
                grass.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
                break;
            case DIRT:
                dirt.draw(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE);
                break;
            }
        }
    }

How can I convert this code to replace the array map with a 2 dimensional arraylist so I can remove these tiles like minecraft?

  • 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-06-14T04:21:52+00:00Added an answer on June 14, 2026 at 4:21 am

    Try

    ArrayList<ArrayList<Integer>> map = new ArrayList<ArrayList<Integer>>();
    

    Basically you are create an array list of array lists which in turn are lists of integers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now, I have this code where $obj_arr maybe contain array and an object.
I have this code right here, where the $friends variable is an array with
Right now I have def min(array,starting,ending) minimum = starting for i in starting+1 ..ending
So I have this array in a header file like this: // header.h static
I have three array, like this, that contains my bitmap images: static unsigned char
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
Right now I have a function which takes my uploaded file, checks the extension,
How do I form a multidimensional array using MySQL data? I'm using this code
I have filled an array of this object and I think I'm filling it

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.