aspose file tools*
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
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: 14688
    
  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: 14688
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Type Mismatch - why i am getting this error?