• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception in java.math.BigDecimal  RSS feed

 
siva prakashmahendran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String re = "0.00";
BigDecimal totalrev = new BigDecimal(re);

String rev1 = (String)empSalesRevenueOm.get(loginid);
BigDecimal amount1 = new BigDecimal(rev1);
I got 138731.72 kind of value in rev1 variable

so when i add rev and totalrev

totalrev = amount1.add(totalrev);


i Got the following exception

Exception in java.math.BigDecimal.<init>(BigDecimal.java:647) :java.lang.NullPointerException


Need Help Thanks in Advance


 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code that you posted seems to work correctly. That null pointer exception occurs elsewhere. Can you post your actual code and printstack of the error you get?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check the source code of BigDecimal by unpacking the src.zip file in your JDK folder.

Anyway, I checked for you, and line 647 is this: So that means that for the exception to come from this line you have somewhere a call to new BigDecimal with a null string. Since re isn't null and you say rev1 isn't null you must look further into the stack trace. Check the lines below that line of the stack trace until you find a line from your code. That's where you're passing a null string.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!