Sunday 15 January 2012

java - How are array object created when using a bracketed list -


I understand that the array is created in object java I call its creator with new keyword:

  int [] myIntArray = new int [3];   

But if I instead

  int [] myIntArray = {1,2,3};   

An array becomes an object, but I have not said its constructor with the new . How does this work under the hood - How can an object be made in Java without calling the manufacturer?

As far as forming an array object, this syntax is compiled when it is compiled, this standard Works just like syntax.

The difference here is that with the first version, you are not populating the array - all elements are int , which is zero.

With the second edition, you are creating, popularizing the and array.

No comments:

Post a Comment