+ 1

In java how to change int var into float or double??

is it possible?

28th Feb 2018, 3:09 PM
nithish kumar
nithish kumar - avatar
3 Respuestas
+ 12
Use type-casting: int number = 5; double d = (double) number;
28th Feb 2018, 3:14 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 2
into double public class IntToDouble{ public static void main(String args[]){ int i=200; double d=i; System.out.println(d); }}
28th Feb 2018, 3:15 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
into float public class Conversions { public static void main(String args[]) { int i1 = 10; // 4 bytes float f1 = i1; // int is type converted to float System.out.println("int value: " + i1); // prints 10 System.out.println("Converted float value: " + f1); // prints 10.0 } }
28th Feb 2018, 3:17 PM
Sudarshan Rai
Sudarshan Rai - avatar