Conversion Value in the AssignmentConverting the value of a variable to another variable can be done with the following requirements:
• Two compatible data types
• Type of interest must be greater scope than other types of sources.
For example, the source integer into String destination.
Syntax as follows:
static int parseInt (String s)Parameter Explanation:
static int parseInt (String s, int radix)
The program conversion Java example as follows:
|coding result, in the above example is the conversion from Integer to Double, and Double to Integer|
Type Casting against type that does not Compatible
Cast is an instruction to the compiler to convert one type to the other. The syntax is as follows:
(Target-type) expressionExamples coding Java programs using a cast:
|java coding results cast|