- public class SampleConversion{
- public static void main(String[]args){
- //upcasting float literal to double
- double doubleVar = 5.55f;
- System.out.println(doubleVar);
- //converting double literal to float
- //Just like other primitive types,
- //downcasting double to float can
- //cause data loss if the double
- //value that is gonna be casted exceeds
- //the bit range of float. Double is
- //64bits whereas float is 32bits
- float floatVar = (float)200.598333d;
- System.out.println(floatVar);
- }
- }