4.3.9 생성자 by ys

  • 생성자는 새로운 연산자를 사용해서 호출할 수 있다.

  • primitive type(원시 타입 int, double등..)과 String 외에는 모두 정규화된 클래스명을 사용해야 한다.

new연산자 를 사용하여 생성자를 호출 할 수 있습니다 . 원시 형 ( int,, float등등)과 String 을 제외한 모든 클래스에 대해 정규화 된 클래스 이름을 사용해야합니다 . 다음 예제에서는 new연산자를 사용하여 생성자를 호출 하는 방법을 보여줍니다 .

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

//create new inventor instance within add method of List
p.parseExpression(
        "Members.add(new org.spring.samples.spel.inventor.Inventor(
            'Albert Einstein', 'German'))").getValue(societyContext);

Last updated