Difference in Array initialization

后端 未结 5 1094
故里飘歌
故里飘歌 2021-01-20 23:40

While looking over a source file, i saw two ways of array initialization. I wonder is there a difference between

int[] value = new int[0];

and<

5条回答
  •  死守一世寂寞
    2021-01-21 00:40

    Now the proof (and an exercise):

    Create two classes, each containing one declaration. Compile them to get .class files.
    On each of the two created files, do:

    javap -c yourClass
    

    To see the bytecode.

    Now you can answer your own question.

提交回复
热议问题