+ 1

How to copy an array integers to another variable?

for example : int var[]={9}; int someCopy = var[0]; // copy value, assume this is a wrong example int newVar=18; var[0]=newVar; // assign newVar to var[0] how to print someCopy but the value of array var before doesn't change?

17th Jun 2018, 1:45 AM
sherlockholmes
sherlockholmes - avatar
2 Answers
+ 2
System.out.print(someCopy[0]) //should print out the value of var before change. should print out 9
17th Jun 2018, 2:33 AM
Andre Daniel
Andre Daniel - avatar
+ 1
i'll try it
17th Jun 2018, 2:59 AM
sherlockholmes
sherlockholmes - avatar