All Questions

1447
votes
16answers
851817 views

How to clone or copy a list?

What are the options to clone or copy a list in Python? Using new_list = my_list then modifies new_list every time my_list changes. Why is this?
702
votes
29answers
396568 views

What is the difference between a deep copy and a shallow copy?

What is the difference between a deep copy and a shallow copy?
591
votes
20answers
833038 views

How do I copy an object in Java?

Consider the code below: DummyBean dum = new DummyBean(); dum.setDummy("foo"); System.out.println(dum.getDummy()); // prints 'foo' DummyBean dumtwo = dum; System.out.println(dumtwo.getDummy()); // p...
208
votes
16answers
154700 views

How to copy files from 'assets' folder to sdcard?

I have a few files in the assets folder. I need to copy all of them to a folder say /sdcard/folder. I want to do this from within a thread. How do I do it?
403
votes
15answers
244617 views

Standard concise way to copy a file in Java?

It has always bothered me that the only way to copy a file in Java involves opening streams, declaring a buffer, reading in one file, looping through it, and writing it out to the other steam. The we...
1242
votes
14answers
953802 views

How do I copy a file in python?

How do I copy a file in Python? I couldn't find anything under os.
250
votes
10answers
532634 views

Make copy of array Java

I have an array A which is constantly being updated. Lets say A = [1,2,3,4,5]. I need to make an exact duplicate copy of A and call it B. If A were to change to [6,7,8,9,10], B should still be [1,2,3,...
388
votes
17answers
232867 views

Copy the entire contents of a directory in C#

I want to copy the entire contents of a directory from one location to another in C#. There doesn't appear to be a way to do this using System.IO classes without lots of recursion. There is a method...
409
votes
15answers
352789 views

Javascript fastest way to duplicate an Array - slice vs for loop

In order to duplicate an Array in Javascript, does anyone know (and maybe tested) if it's faster to use: Slice method: var dup_array = original_array.slice(); or For loop: for(var i = 0, len = o...
85
votes
8answers
39529 views

Why should the copy constructor accept its parameter by reference in C++?

Why must a copy constructor be passed its parameter by reference?

Previous Next