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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:02:52+00:00 2026-05-16T15:02:52+00:00

When you call the clone() method of an ArrayList, a shallow copy of the

  • 0

When you call the clone() method of an ArrayList, a shallow copy of the list is created.
what is shallow copy of array?

  • 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-16T15:02:53+00:00Added an answer on May 16, 2026 at 3:02 pm

    You should distinguish between two kinds of copy: shallow and deep.

    While deep copy allocates new space for the whole array and all its content (if it contains references, then new space is allocated to create instances with the same values of the ones copied), shallow copy just allocates space with the same size of the copied array.

    Example:

    Array A has been allocated to contain only two mutable objects ( e.g.: a list or an arraylist).
    Do you want to have just a copy of the “extern” array (the one that contains the two references) or do you want a deep copy, that will allocate also new instances of the two references contained in A ?

    In the first case, for example:

    A is the array starting at reference 0x0000AA

    ElementOne starts at 0x00BBCC

    ElementTwo starts at 0x00BBFF

    If you execute a shallow copy:

    B (the new array) will start at reference 0x0000BB,
    ElementsOne and ElementsTwo will point to the old references (0x00BBCC, 0x00BBFF).

    If you execute a deep copy, not only it allocates the new space for the array, but it also allocates space to contain the new instances (a new list, a new arraylist …).

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

Sidebar

Related Questions

I thought that to clone a List you would just call: List<int> cloneList =
The clone() system call on Linux takes a parameter pointing to the stack for
It is said that fork system call creates a clone of the calling process,
I have created a bare git repo (lets call it repo #1) and cloned
Call to undefined method after upgrading to PHP 5.4.0 mentions a few APC bug-reports
List CreateNewStatements(ForLoop L) { List stmts = new ArrayList(); FlatIterator iter = new FlatIterator(L.getBody());
I know that there is a clone() method in Object class which is declared
I have a quick question regarding the clone() method in Java, used as super.clone()
I'm trying to call a server side method, using jquery, on the textchange event
I have an ArrayList<String> that I'd like to return a copy of. ArrayList has

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.