aspose file tools*
The moose likes Java in General and the fly likes java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal" Watch "java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal" New topic
Author

java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal

Kanwardeep Singh
Greenhorn

Joined: Dec 06, 2012
Posts: 10
I am getting a BigDecimal Through a getter method and putting that into a Map<String,Object[]>
that bigdecimal is part of the Object[] Array.
but i am getting this ClassCastException.

While fetching that array value and setting into Object[]
Map<String,Object[]> map=HashMap<String,Object[]>();
map.put("1",new Object[] { l_obj.getValueOfBigDecimal()})
I am getting this Execption.

Can anyBody help?
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Can you show the full stacktrace please? That will give us a better idea as to where the problem is occurring. I suspect there is an issue with your get method.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
Are you putting the BigDecimal object into the Object[] or into the Map?
Kanwardeep Singh
Greenhorn

Joined: Dec 06, 2012
Posts: 10
yes..i am putting BigDecimal into Object[] ar. and Object[] ar i am putting into Map.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

But the exception would be thrown when you are getting the data out of the map, so why aren't we seeing that code? James Boswell asked you to post it quite a long time ago.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException: java.lang.String cannot be cast to java.math.BigDecimal