Type conversion from java BigDecimal type to String type

It seems that java originally has a class called BigDecimal.

Declaring a variable of type BigDecimal for the first time I thought that I should use the valueOf () method when I finally wanted to convert a variable of BigDecimal type to String type, but it seems that BigDecimal has a method for type conversion.

sample スクリーンショット 2020-06-10 16.09.28.png

First of all, the variable declaration & initialization of BigDecimal type is done at the top. There are 3 variables (right, left, decimalValue) in all.

Next, in the switch statement, the calculation results of right and left are stored in decimalValue.

And the point of interest is type conversion. String decimalValue1 = decimalValue.toString(); The part of is type conversion.

First, prepare decimalVlue1 to put the converted value Next, the decimalValue is converted using the method that BigDecimal has called toString ().

Recommended Posts

Type conversion from java BigDecimal type to String type
[Java] Conversion from array to List
Java type conversion
Java date data type conversion (Date, Calendar, String)
[Java] Convert Object type null to String type
Java 8 LocalDateTime type conversion stuff (String, java.util.Date)
[Java] How to convert from String to Path type and get the path
Changes from Java 8 to Java 11
Sum from Java_1 to 100
URL to String conversion
Uri → String, String → Uri type conversion
From Java to Ruby !!
[Java] Date type conversion
Convert from C String pointer to Swift String type
[Introduction to Java] About type conversion (cast, promotion)
Java type conversion (String, int, Date, Calendar, etc.)
[Java] List type / Array type conversion
Migration from Cobol to JAVA
Convert String type to Timestamp type
New features from Java7 to Java8
[Java] Type conversion speed comparison
[Java] How to erase a specific character from a character string
Java Primer Series (Type Conversion)
From Ineffective Java to Effective Java
How to store a string from ArrayList to String in Java (Personal)
Initialization with an empty string to an instance of Java String type
I tried to convert a string to a LocalDate type in Java
Change only one character from the String type string to uppercase
Java to be involved from today
Java, interface to start from beginner
The road from JavaScript to Java
How to use Java enum type
Java string
[Convenient to remember !!!] How to convert from LocalDate type to character string and from character string to LocalDate type
[Java beginner] Conversion from character string to numerical value-What is the parseInt method of the Integer class? ~
Regarding String type equivalence comparison in Java
Use PostgreSQL data type (jsonb) from Java
[Java ~ Variable definition, type conversion ~] Study memo
[Java] Data type / string class cheat sheet
Java study # 3 (type conversion and instruction execution)
Convert from java UTC time to JST time
How to do base conversion in Java
Connect from Java to MySQL using Eclipse
How to output Java string to console screen
Post to Slack from Play Framework 2.8 (Java)
Java: How to send values from Servlet to Servlet
[Basic knowledge of Java] About type conversion
[Java] Flow from source code to execution
Introduction to monitoring from Java Touching Prometheus
Precautions when migrating from VB6.0 to JAVA
[Java] Calculation mechanism, operators and type conversion
Memo for migration from java to kotlin
[Java] From two Lists to one array list
Upsert from Java SDK to Azure Cosmos DB
[Java] How to convert one element of a String type array to an Int type
Run R from Java I want to run rJava
Connect to Aurora (MySQL) from a Java application
[Java] String padding
[Java] Enumeration type
Java Optional type
Code to escape a JSON string in Java