此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring Framework 6.2.10spring-doc.cadn.net.cn

构造 函数

您可以使用new算子。 您应该使用完全限定的类名 对于所有类型,但位于java.lang包 (Integer,Float,String,依此类推)。还支持 varargsspring-doc.cadn.net.cn

以下示例演示如何使用new运算符调用构造函数。spring-doc.cadn.net.cn

Inventor einstein = parser.parseExpression(
	"new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German')")
		.getValue(Inventor.class);

// create new Inventor instance within the add() method of List
parser.parseExpression(
	"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
		.getValue(societyContext);
val einstein = parser.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
parser.parseExpression(
	"Members.add(new org.spring.samples.spel.inventor.Inventor('Albert Einstein', 'German'))")
		.getValue(societyContext)