|
对于最新的稳定版本,请使用 Spring Framework 7.0.6! |
构造函数
您可以使用 new 运算符调用构造函数。对于除位于 java.lang 包中的类型以外的所有类型,应使用完全限定的类名(Integer、Float、String 等)。下面的示例显示了如何使用 new 运算符来调用构造函数:
-
Java
-
Kotlin
Inventor einstein = p.parseExpression(
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
.getValue(Inventor.class);
// create new Inventor instance within the add() method of List
p.parseExpression(
"Members.add(new org.spring.samples.spel.inventor.Inventor(
'Albert Einstein', 'German'))").getValue(societyContext);
val einstein = p.parseExpression(
"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
.getValue(Inventor::class.java)
// create new Inventor instance within the add() method of List
p.parseExpression(
"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
.getValue(societyContext)