What does suffix 'f' mean in Java code?

前端 未结 5 1323
夕颜
夕颜 2020-12-03 22:21

Here\'s the explanatory code. The language is Java and the code uses Android.

fg.setTextSize(height*0.50f); //<-\'f\' is in the brackets

相关标签:
5条回答
  • 2020-12-03 22:53

    It indicates 3 is float not integer in other case 0.50 is float not double. Just like in any other java program.

    0 讨论(0)
  • 2020-12-03 22:59

    It's a float, not a double. This is basic Java (C) notation.

    0 讨论(0)
  • 2020-12-03 23:11

    float ;)

    it's a 3 that is a float, not an int

    0 讨论(0)
  • 2020-12-03 23:11

    You don't need to append the f if entering 0 or 1 or during certain assignments. But other times you do need it especially when the compiler can't tell if its a float or a double or an int or needs to cast the value in some way. It's maddeningly inconsistent really.

    0 讨论(0)
  • 2020-12-03 23:14

    It indicates a float literal.

    0 讨论(0)
提交回复
热议问题