Answers for "array creating a copy"

5

java copy array

int[] a = {1,2,3,4,5};
int[] b = Arrays.copyOf(a, a.length);
Posted by: Guest on April-25-2020
3

javascript copy array

var numbers = [1,2,3,4,5];
var newNumbers = Object.assign([], numbers);
Posted by: Guest on April-09-2020
3

javascript copy array

// this is for array with complex object
var countries = [
  {name: 'USA', population: '300M'}, 
  {name: 'China', population: '1.6B'}
];

var newCountries = JSON.parse(JSON.stringify(countries));
Posted by: Guest on April-09-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language