在 Java 中,您可以执行以下操作:
new Object[] { /* parameters separated by comma */};
的确,这是在Spring框架的prepared statements中使用的。 例如:
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
);
- 这个怎么称呼?
- 那里发生了什么事?
- 您如何访问这些参数?
最佳答案
Object[] objs = new Object[]{3,4};
等同于:
Object[] objs = new Object[2];
objs[0] = 3;
objs[1] = 4;
所以你访问它是objs[0];
关于java - Java 中的 new Object[]{} 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20054481/