aspose file tools*
The moose likes Beginning Java and the fly likes Constructor returns an object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Constructor returns an object?" Watch "Constructor returns an object?" New topic
Author

Constructor returns an object?

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
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.

We must know, we will know. -- David Hilbert
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

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.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Either that or they forgot to add the new keyword.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ogeh Ikem
Ranch Hand

Joined: May 13, 2002
Posts: 180
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

Joined: Jan 29, 2005
Posts: 327
Thank you guys.
 
jQuery in Action, 2nd edition
 
subject: Constructor returns an object?