This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Spring and the fly likes Type Mismatch - why i am getting this error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Type Mismatch - why i am getting this error?" Watch "Type Mismatch - why i am getting this error?" New topic
Author

Type Mismatch - why i am getting this error?

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

My code looks like below:



Here i am using getBean() method with argument classtype. Why i am getting the error :
Type mismatch: cannot convert from Object to Car



Anything i am missing or doing wrong?

Thanks
Sudhakar
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yeah, you're not casting.
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

David Newton wrote:Yeah, you're not casting.


Thanks David for your reply..

But here i am giving the type of the object as second argument in the getBean method..

Is it not the right way?

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Where are you getting this warning ? In an editor ?


[My Blog]
All roads lead to JavaRanch
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Christophe Verré wrote:Where are you getting this warning ? In an editor ?


I am getting this warning in eclipse
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Which version of Spring are you using ? If you are using a version prior to 3.0, then you'll need to cast. From Spring 3.0, getBean uses generics, so you don't need to cast.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Type Mismatch - why i am getting this error?
 
Similar Threads
Overriding protected method
Regarding Generics wildcards
problem with Date validations thru Validator-rules.xml and Validation.xml
out.print ln dynamic form value picking
Equivalent field for nclob in java