Can someone please give the Java equivalent of the below python (which slices a given array into given parts) which was originally written by ChristopheD here:
def split_list(alist, wanted_parts=1):
length = len(alist)
return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
for i in range(wanted_parts) ]
I don’t know any python but can really use the above code in my Java app. Thanks
Maybe something like this:
If your
alistwill be structurally modified later in any way, you will have to make a copy of the sublist created by thesubListmethod within the code, otherwise the results will be unpredictable.