0
Can anyone tell me what is the return type of Math.rint() ?
Because in Google it is showing double but in my book it is showing int as return type
3 Answers
+ 3
Math.rint() returns double according to https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html
Online docs are supposedly more updated than printed books.
+ 3
Hello Atul
Math.rint() returns double.
https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/lang/Math.html#rint(double)
You can also test it if you just try to assign it to an integer.
int x = Math.rint(2.3);
+ 2
Thank you all