• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructor returns an object?

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen this code snippet:



http://static.springsource.org/spring/docs/3.0.0.RC1/spring-framework-reference/html/ch05s04.html

How could this work? As far as I know it's only allowed to call a constructor after the "new" keyword.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with Spring, but the line of code you posted implies that the class in which it's written has a method BeanWrapperImpl (or has a static import for that static method of another class) which takes can take a Company argument.

Someone please correct me if that's wrong in the Spring context.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either that or they forgot to add the new keyword.
 
Ogeh Ikem
Ranch Hand
Posts: 180
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like an error. It should be new BeanWrapperImpl(new Company()) as shown here.

The BeanWrapperImpl class has many overloaded constructors.
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic