Ordo Ordo - 2 months ago 7
Java Question

Using abs () method in java. My compiler doesn't know the method

I have a simple question, but i can't find a solution for it.

I want to use

the abs ()
method but it doesn't work. I'm always getting the
Error:" Cannot find symbol: method abs(int)".


I have already tried to use the method by including
"import java.math"
above the code. But that doens't work too.

Answer

Are you using:

Math.abs()

or just

abs()

?

Use Math.abs()

Comments