Conversion is changing from one data type to another. In Java and it's relatives, this is called casting.
Most commonly, this is used to convert strings to numbers. The reason being that text fields on forms/pages pass the information to the program as strings.
There are two types of conversions (casts):
This occurs when you allow the program to due the conversion (cast) for you. Generally speaking, it only works if:
- you are converting numbers to string
- you are converting a low-precision number to a higher precision number (integer to a long)
Visual Basic Message = "I have been progamming for " & YearsProgramming Java Message = "I have been progamming for " + YearsProgramming
ExplicitYou specifically tell the program that you want to do the conversion (cast). Generally speaking, this must be done if:
- you are converting strings to numbers
- you are converting a high-precision number to a lower precision number (long to integer)
Visual Basic YearsProgramming = CInt(YearsProgrammingField) Java yearsProgramming = Integer.parseInt(yearsProgrammingField)