Before we start converting one datatype to another, lets read up about available datatypes in java: http://mycodedock.blogspot.in/2013/11/data-types-in-java.html
In-fact, lets establish a few thumb-rules-
In-fact, lets establish a few thumb-rules-
- whenever converting smaller-bit datatypes to larger-bit datatypes we use Implicit Casting.
- whenever converting larger-bit datatypes to smaller-bit datatypes we use Explicit Casting.
- boolean datatype cannot be converted to any other datatype
- conversion from string type to any other datatype needs the string to be parsed
- conversion of any datatype (except boolean) to string needs to be done by passing value
Now you know all datatype conversion techniques that are used in java. Though, you might want to brush your skills up by some practice.