Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Difference between float "1" and float "1f" in Java?

Is there any difference - in Java - between defining float variables like, e.g., this: 1 and this: 1f? Is the JVM doing any casts at run-time when I write 1, or something that could slow down my app?

Regards

like image 920
m4tx Avatar asked Nov 17 '25 20:11

m4tx


1 Answers

1 is implicitly considered as int literal where 1f is considered as float literal

See

  • Floating point literal
like image 108
jmj Avatar answered Nov 19 '25 09:11

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!