Java learning: why float a = 5.6; compile error ?

why can't float a = 5.6; ?

 error: incompatible types: possible lossy conversion from double to float         float a = 5.6;                   ^ 1 error 

Cause

double is the default type of floating point number in java language.

Fix

 float a = 5.6f; 

No comments:

Post a Comment

How to Set Up Giscus Comments for Your Website

  How to Set Up Giscus Comments for Your Website If you want to add a clean, GitHub-powered comment system to your website,   Giscus   is on...