How can I slice an ArrayList out of an ArrayList in Java?

前端 未结 5 1980
故里飘歌
故里飘歌 2020-12-02 16:10

How do I get an array slice of an ArrayList in Java? Specifically I want to do something like this:

ArrayList inputA = input.sub         


        
5条回答
  •  被撕碎了的回忆
    2020-12-02 16:53

    Although this post is very old. In case if somebody is looking for this..

    Guava facilitates partitioning the List into sublists of a specified size

    List intList = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8);
        List> subSets = Lists.partition(intList, 3);
    

提交回复
热议问题