- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to create a BigDecimal from a string type value
Let us first create a BigDecimal type with string value −
BigDecimal one = new BigDecimal("562537627.8787867");
Now, create a BigDecimal with long −
BigDecimal two = BigDecimal.valueOf(562L);
After that use add() with the aug end value i.e. the value in “two” object −
one = one.add(two);
Example
import java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { BigDecimal one = new BigDecimal("562537627.8787867"); BigDecimal two = BigDecimal.valueOf(562L); one = one.add(two); System.out.println(one); } }
Output
562538189.8787867
- Related Articles
- Create a BigDecimal via string in Java
- Java Program to divide one BigDecimal from another BigDecimal
- Java Program to convert a Primitive Type Value to a String
- Negate a BigDecimal value in Java
- Java Program to create a boolean variable from string
- Create BigDecimal Values via a long in Java
- Java Program to Create String from Contents of a File
- Java Program to create Stream from a String/Byte Array
- Java Program to round a double passed to BigDecimal
- Java Program to create String to super class type mapping
- Subtract one BigDecimal from another BigDecimal in Java
- Truncate BigDecimal value in Java
- Python program to create a dictionary from a string
- Java Program to convert a String to a float type Number
- How to create a string from a Java Array?

Advertisements