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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:31:02+00:00 2026-05-15T17:31:02+00:00

OK let’s say I have this array: public int[][] loadBoard(int map) { if (map

  • 0

OK let’s say I have this array:

public int[][] loadBoard(int map) {

    if (map == 1) {  return new int[][] { 
{2,2,24,24,24,24,24,1,3,0,0,0,1 },  {
2,2,24,23,23,23,24,1,3,0,0,0,1 },  {
1,1,24,23,23,23,24,1,3,3,3,3,1 },  {
1,1,24,24,23,24,24,1,1,1,1,3,1 },  {
1,1,1,1,7,1,1,1,1,1,1,3,1 },  {
6,1,1,1,7,7,7,7,7,1,1,1,1 },  {
6,3,3,1,3,3,3,1,7,7,7,3,1 },  {
6,72,3,3,3,1,1,1,1,7,7,1,1 },  {
3,3,3,3,1,1,1,1,1,1,7,1,1 } };  } }
return board;

and I can call it doing this:

board = loadBoard(1);

But… let’s say I want to change the number 72 on map 1 array (bottom-left in the array) to the number… 21. Can you do that?

  • 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-15T17:31:03+00:00Added an answer on May 15, 2026 at 5:31 pm
    board[7][1] = 21;
    

    Explanation: When dealing with an array a[], a[n] references the (n+1)th element (keeping in mind the first element is a[0].

    A multidimensional array is just an array of arrays. So if you have a 2D array b[][], then b[n] references the (n+1)th array.

    Your value 72 is in the 8th array (index 7), at the 2nd position (index 1). Therefore board[7][1] references that value, and board[7][1] = 21 assigns it the value 21.

    Aside: Sometimes (usually, even) you don’t know when you write the code which indexes you want to work with, (say you want to do it generically for all maps). This code will find all occurrences of 72 and replace them with 21:

    int numToReplace = 72;
    int replacement = 21;
    //loop through each nested array
    for ( int i = 0; i < board.length; i++ ) { 
       //loop through each element of the nested array 
       for ( int j = 0; j < board[i].length; j++ ) { 
          if ( board[i][j] == numToReplace ) {
             board[i][j] = replacement;
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can make changes to use IDbConnection and IDbCommand (use… May 16, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer Are you wanting to calculate this in order to say… May 16, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer SQL Server allows connection via four different protocols: Shared Memory… May 16, 2026 at 9:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Let's say I have this: public DefaultListModel model = new DefaultListModel(); how do i
Let's say I have a class like this: public class Person { private String
Let's say I have two entities: Physician Credentials And a physician can have many
Let's say I have a table that looks something like this: ------------------------------- id|column2|column3 |column4
Let's say I'm building a data access layer for an application. Typically I have
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say we have a simple function defined in a pseudo language. List<Numbers> SortNumbers(List<Numbers>
Let's say I have a drive such as C:\ , and I want to
Let's say that we have an ARGB color: Color argb = Color.FromARGB(127, 69, 12,
Let's say that I have an arbitrary string like `A man + a plan

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.