Java code translation of Python array-splitting code

Posted by techventure on Stack Overflow See other posts from Stack Overflow or by techventure
Published on 2010-05-24T08:21:35Z Indexed on 2010/05/24 8:41 UTC
Read the original article Hit count: 275

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about java

Related posts about python