Question 19
Back to Exercise
Why does new BigDecimal("2.0").equals(new BigDecimal("2.00")) return false?
- A A bug
- B BigDecimal.equals compares both value and scale; use compareTo for numeric equality Correct
- C Strings are compared
- D They are different numbers
Correct Answer: Option B
compareTo returns 0 for them.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!