I want to fill in part of an array with the values of another array. Is there anyway I can do this without looping?
eg
int [] [] ArrayToFillIn = new int [3] [3]
int [] FillingArray = {1, 2};
for (int i = 1; i < 3; i++)
{
ArrayToFillIn [i-1] [2] = FillingArray [i - 1];
}
in R it would be like:
ArrayToFillIn [c(1:2),3] = FillingArray []
(considering that R does not start from 0)
Thanks!
Sure. Without a loop it would be
ArrayToFillIn [0] [2] = FillingArray [0];
ArrayToFillIn [1] [2] = FillingArray [1];
What with this initialization:
int [] FillingArray = {1, 2};
int [][] ArrayToFillIn = new int[][]{{0, 0, FillingArray[0]}, {0, 0, FillingArray[1]}, {}};
//---------------------------------------------^-----------------------^----------------^
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.