Is it faster (or better) to declare an array inline in Java?

前端 未结 7 1258
慢半拍i
慢半拍i 2021-01-11 17:20

Consider the following two method calls that are nearly equivalent. Take note of the way the byte array is declared and allocated on both.

void Method1()
{
          


        
7条回答
  •  醉酒成梦
    2021-01-11 17:44

    These 2 methods are exactly equivalent. However second method is more verbose and less convenient for longer arrays or if you want to modify the array length.

提交回复
热议问题