This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 4523
    
    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: 19557
    
  16

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructor returns an object?
 
Similar Threads
spring files
What are the new features of Spring 3?
File Upload
Validation is not working in Annotaion based controller
hi, i am a very very beginner of spring framework. So, Please give some suggestion.