- 2

Which package is needed to find the square root . java.lang or java.math

9th Jul 2021, 11:33 AM
Firoz Khan
Firoz Khan - avatar
6 ответов
+ 2
If you are in a hurry – why not google "java square root"? Anyways, this seems to work: Math.sqrt(x) (x is double)
9th Jul 2021, 11:46 AM
Lisa
Lisa - avatar
+ 1
Test or interview?
9th Jul 2021, 12:32 PM
Oma Falk
Oma Falk - avatar
+ 1
Firoz Khan Java.long is default package , no need to import. You can use directly sort() method as it is static method in Math class like Math.sqrt(Number); it returns squire root of Number. No need to import any package explicitly....
9th Jul 2021, 12:36 PM
Jayakrishna 🇮🇳
0
One could do a quick test on sololearn playground and see that java.lang.Math.sqrt() and Math.sqrt() works and that java math.sqrt() throws an error. Without knowing much Java I would infer that Math.sqrt() is built-in part of java.lang so we usually don't need to write this part explicitly
9th Jul 2021, 12:37 PM
Lisa
Lisa - avatar
- 2
Please give me answer quickly
9th Jul 2021, 11:44 AM
Firoz Khan
Firoz Khan - avatar
- 2
I want to know java.lang or java.math
9th Jul 2021, 12:19 PM
Firoz Khan
Firoz Khan - avatar