What does new Object[]{} in Java means?

java

Solution

Object[] objs = new Object[]{3,4};

is the same as:

Object[] objs = new Object[2];
objs[0] = 3;
objs[1] = 4;

So you access it as objs[0];

Problem

In Java you are able to do the following: ``` new Object[] { /* parameters separated by comma */}; ``` Indeed, this is used in the prepared statements of the Spring framework. Eg: ``` getJdbcTemplate().queryForList( "DELETE FROM foo WHERE id = ?", //the "?" mark will be substituted by "3" new Object[] { 3 }, //What kind of magic is this? String.class //Irrelevant in this example ); ``` - How is this called? - What is going on there? - How could you access that parameters?

Original source