What is the difference between BigDecimal bd = new BigDecimal (1) and BigDecimal bd = new BigDecimal("1") ? We are using java 1.4
Please let me know about the same.
Thank you in advance.
I went through the docs before posting here..Was not able to get clear answer. BigDecimal = new BigDecimal("1") creates new object with 1 as string...while BigDecimal = new BigDecimal(1) is as BigInteger...but in any case it should work. But this program is failing.
And always tell us what is going wrong.
Hd Desai wrote:But this program is failing.
just as a tip for next time...just saying "my program doesn't work" is really pointless. There are thousands of ways it could "not work". One of three things should be happening:
1) You get a compiler error. If so, tell us the EXACT text of that error. There is a LOT of info there, once you learn how to read it
2) Your program crashes when it runs. Again, you'll get some kind of message telling you what went wrong.
3) Your program runs, but behaves differently than you expect. We don't know what you expect, nor do we know what it does do. You need to tell us both.
You will find you generally get much more help, better help, and quicker help, if you do the above.
Hd Desai wrote:Thank you for response Jeff.
I went through the docs before posting here..Was not able to get clear answer. BigDecimal = new BigDecimal("1") creates new object with 1 as string...while BigDecimal = new BigDecimal(1) is as BigInteger
It says a lot more than that. You probably ought to read it, very closely. And a little bit of thinking and effort would have led you to try something like this:
...but in any case it should work. But this program is failing.
Saying it "should work" is meaningless. It's doing exactly what it should do. The problem is that you have erroneous assumptions about how a given bit of code "should" behave.
And note that ItDoesntWorkIsUseless.(⇐click) You need to TellTheDetails(⇐click) so that people here will understand exactly what is going wrong.
What has an int got to do with it? You said earlier you were not using whole numbers throughout. So some of your code uses the BigDecimal(int) constructor and the rest the BigDecimal(double) constructor? As Jeff has said, we need to know the correct details before we can help.
Hd Desai wrote:thanks again Ritchie...yes I read whole doc..and it was my mistake i was reading 1.5 javadoc...
BigDecimal constructor does not take int till 1.5 . . . .