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

  • SEARCH
  • Home
  • 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 8365469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:39:48+00:00 2026-06-09T12:39:48+00:00

I was working with relatively large String arrays today. (Roughly 400 x 400 in

  • 0

I was working with relatively large String arrays today. (Roughly 400 x 400 in size) I was wondering how making one array equal to another works exactly. For instance,

String[][] array1 = new String[400][400];
String[][] array2 = array1;

Is making one array equal to another the same thing as looping through each element and making it equal to the respective position in another array? (Like below)

for(int y = 0; y < 400; y++) {
    for(int x = 0; x < 400; x++) {
        array2[x][y] = array1[x][y];
    }
}

Now is the looping method the same thing as making one array equal to another? Or is the first/second faster than the other? Personally, I think the first would be faster just because there is no recursion or having to manually allocate memory to array2 before the recursion. But, I have no idea where to start looking for this information and I would like to understand the logistics of how Java processes these kinds of things.

  • 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-09T12:39:50+00:00Added an answer on June 9, 2026 at 12:39 pm

    No, it is not the same thing: arrays are reference objects, so array2 becomes an alias of array1, not its copy. Any assignment that you make to an element of array2 become “visible” through array1, and vice versa. If you would like to make a copy of a single-dimension array, you can use its clone() method; note that the copy will be shallow, i.e. the individual elements of the array will not be cloned (making the trick inapplicable to the 2-D array that you described in your post).

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

Sidebar

Related Questions

I am trying to generate a unique string/id given another relatively large string(consisting of
I am currently working on a large project and will relatively soon need a
I'm relatively new to working with XML and am working with some rather large
I'm working on a project involving enlisting a large number of relatively unskilled workers
Working with a relatively large data set I have a situation where I need
First some background, I am currently working on a relatively large Asp.Net MVC application
I'm working with a relatively large SQL Server 2000 DB at the moment. It's
I'm currently working on a relatively large MVC project I would like to organize
So I've been working on a relatively large project by myself, and I've come
I have a relatively large class that I'm working with and it's all worked

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.