Java question | Sololearn: Learn to code for FREE!

+1

Java question

Can i do this in java? double pi = Math.PI();

4/17/2021 4:29:28 PM

Eric

4 Answers

New Answer

+8

Eric No you can do Math.PI not Math.PI() PI is not a method it's a value. In Math class it is declared as public static final double PI = 3.14159...;

+3

Maybe it would be like this: https://code.sololearn.com/cA0A0a7A04A1

0

PI is a variable, not a method.

0

You should use it as a value. And since Pi is constant (3.14) keep it as double pi = 3.14 Or if you want to input double or int values - https://code.sololearn.com/c1iL1xRzvUN5/?ref=app https://code.sololearn.com/ceBz8V7JzLy3/?ref=app