0
How can I convert int, float and other numbers to String type?
when i try to act stupid and be like string x; int y = 67; x = (string) 67; it throws an error in me
3 Answers
+ 6
or just use String.valueOf(variable)
+ 4
public class Program
{
public static void main(String[] args) {
Integer x = 2016;
Float f = 2017.12;
Double d = 2018.01;
System.out.println(x.toString());
System.out.println(d.toString());
System.out.println(f.toString());
}
}
(Edit)
Cant use primitive types for that : )
Hth, cmiiw
+ 2
Actually, @romangraef has the answer, it's the flexible way to do it : )