In most cases we want to convert our variable values in to other format. We can use cast operator for do this task. You can see some examples below
public class StringToInt { public static void main(String[] args) { String mystring = "78"; // current variable have a string type value int myint = Integer.parseInt(mystring); // convert that value in to integer type System.out.println(myint);// print it } }
Now we will see how to convert Double value to string type
public class DoubleToString { public static void main(String[] args) { double myDouble = 0.11; String myString = Double.toString(myDouble); System.out.println(myString); } }
Same as you can use to convert any type value to another type