This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 1012
    
    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: 38441
    
  23
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: 18541
    
    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