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] How to convert a character string from String type to byte type
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)
URL to String conversion
From Java to Ruby !!
[Java] Date type conversion
Java type conversion (String, int, Date, Calendar, etc.)
[Java] List type / Array type conversion
Migration from Cobol to JAVA
New features from Java7 to Java8
[Java] Precautions for type conversion
[Java] Type conversion speed comparison
Connect from Java to PostgreSQL
[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
From Java to VB.NET-Writing Contrast Memo-
Java, interface to start from beginner
The road from JavaScript to Java
How to use Java enum type
Java string
[Java beginner] Conversion from character string to numerical value-What is the parseInt method of the Integer class? ~
Full-width → half-width conversion with Java String (full-width kana → half-width kana)
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
From installing Eclipse to executing Java (PHP)
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
[Java] Comparison of String type character strings
[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
Run R from Java I want to run rJava
[JAVA] Stream type
[Java] String padding
To become a VB.net programmer from a Java shop
[Java] Enumeration type
Java Optional type
Migrate from Java to Server Side Kotlin + Spring-boot
How to get Class from Element in Java
String operation Try to make Java problem TypeScript 9-3
Java double type