Conversion is basically the process of changing the type of an object into another.
In many cases, an application may need a value of one type to be used differently. Conversions enable expressions of any given type to be suited to the needs of the application.
A common scenario involves fetching a value from a data source that, in most cases, is returned as a generic Object, yet needs to be treated as a string, an integer, a floating-point value, or otherwise.
The following examples illustrate this concept, showing several of the various ways by which type conversion is employed in such situations.
Let’s briefly explore the key concepts and methods used to convert types in those samples.