我想从java中的列表中选择前N个元素
String[] ligature = new String{there,is not,a,single,person,who,knows,the,answer};现在,我想从this.something中选取前5个元素,如下所示
Stiring[] selectedLigature = ligature[0:4];
我想不使用for循环来做这件事。
发布于 2018-08-15 16:45:25
不要流传输这个简单的案例,这里有subList:
// for a List
yourList.subList(0, 5)...
// for an array
Arrays.copyOfRange发布于 2018-08-15 16:45:46
Arrays类对此有一个method:
Arrays.copyOfRange(ligature, 0, 5);https://stackoverflow.com/questions/51855469
复制相似问题