I have this code line:
x
and k
are int
.
lm
is an array
lz=[f(x,lm[:j]+lm[j+1:],k) for j in range(n)]
My question is:
I want to convert the above line into Java...
I have created an lm
array in Java, but I am thinking of making it an arraylist to avoid the problem of the array length.
I know that for instanse lm
is [1, 4, 1, 9]
. Then the output list will be:
[4, 1, 9],[1, 1, 9],[1, 4, 9],[1 ,4,1]
But I am a little bit confused about the way to implement 开发者_如何转开发it in Java ...
Any help is appreciated..Thanks
Will that help you?
int[] lm = new int[] {1, 4, 1, 9};
for (int i = 0; i < lm.length; i++) {
int[] tmp = new int[lm.length - 1];
System.arraycopy(lm, 0, tmp, 0, i);
System.arraycopy(lm, i + 1, tmp, i, lm.length - i - 1);
System.out.println("tmp = " + Arrays.toString(tmp));
}
This of course doesn't use f() as I have no way of knowing what it actually does.
精彩评论