1. public class SampleConversion{
  2. public static void main(String[]args){
  3. //upcasting float literal to double
  4. double doubleVar = 5.55f;
  5. System.out.println(doubleVar);
  6. //converting double literal to float
  7. //Just like other primitive types,
  8. //downcasting double to float can
  9. //cause data loss if the double
  10. //value that is gonna be casted exceeds
  11. //the bit range of float. Double is
  12. //64bits whereas float is 32bits
  13. float floatVar = (float)200.598333d;
  14. System.out.println(floatVar);
  15. }
  16. }