What is float in Java?

前端 未结 4 1924
别那么骄傲
别那么骄傲 2020-12-02 07:41

I wrote this code:

float b = 3.6;

and I get this:

Error:Unresolved compilation problem: 
    Type mismatch: cannot convert from         


        
4条回答
  •  悲哀的现实
    2020-12-02 08:03

    Make it

    float b= 3.6f;
    

    A floating-point literal is of type float if it is suffixed with an ASCII letter F or f; otherwise its type is double and it can optionally be suffixed with an ASCII letter D or d

    • Read More

提交回复
热议问题