Summary of type conversions I often search for
int num = 3;
double number = (double)num;
double num = 3;
int number = (int)num;
Numeric types (such as long) can be converted by adding ** (type to be converted) ** before the variable to be converted.
int num = 3;
String number = Integer.toString(num);
double num = 3.0;
String number = Double.toString(num);
String text = "123";
int number = Integer.parseInt(text);
String text = "123";
int number = Double.parseDouble(text);
Types and type conversion methods other than the above. [Java] Convert String type to int type
Recommended Posts