Is there any difference between “Object[] x” and “Object x[]”?

前端 未结 5 1944
时光说笑
时光说笑 2020-12-03 22:17

I was updating a legacy code base in Java and I found a line like this:

Object arg[] = { new Integer(20), new Integer(22) };

That line catc

5条回答
  •  一个人的身影
    2020-12-03 23:17

    No, they both work. But watch out:

    float anArrayOfFloats[], aSecondVariable;
    

    will declare one array of floats and one float, while:

    float[] anArrayOfFloats, aSecondVariable;
    

    will declare two arrays of floats.

提交回复
热议问题