Any shortcut to initialize all array elements to zero?

后端 未结 14 2777
北恋
北恋 2020-11-28 18:12

In C/C++ I used to do

int arr[10] = {0};

...to initialize all my array elements to 0.

Is there a similar shortcut in

14条回答
  •  悲&欢浪女
    2020-11-28 18:24

    Yet another approach by using lambda above java 8

     Arrays.stream(new Integer[nodelist.size()]).map(e -> 
     Integer.MAX_VALUE).toArray(Integer[]::new);
    

提交回复
热议问题