我有这样的数组,它们在一定范围内:
int[] arr1 = {1,2,3,4,5,6};
int[] arr2 = {7,8,9,10,11};
int[] arr3 = {12,13,14,15,16,17,18,19};
是否存在一种类似于Python的单行方式创建这些列表(可能使用范围函数):
arr = list(range(1, 7))
答案 0 :(得分:3)
int[] result = IntStream.range(startInclusive, endExclusive).toArray();
int[] result = IntStream.rangeClosed(startInclusive, endInclusive).toArray();