Java question | Sololearn: Learn to code for FREE!


Java question

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

4/17/2021 4:29:28 PM


4 Answers

New Answer


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...;


Maybe it would be like this:


PI is a variable, not a method.


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 -