Fill arrays with ranges of numbers

前端 未结 6 621
甜味超标
甜味超标 2020-11-29 06:20

Is there any syntax/package allowing quick filling of java arrays with ranges of numbers, like in perl?

e.g.

int[] arr = new int[1000];
arr=(1..500,3         


        
6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 07:02

    Another useful and not widely known Java 8 solution for existing arrays:

    int[] array = new int[10];
    Arrays.setAll(array, i -> i + 1);
    

提交回复
热议问题