Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

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

I want to use 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.

like image 434
Ordo Avatar asked Dec 10 '10 18:12

Ordo


1 Answers

Call it as

Math.abs(number)

or import as:

import static java.lang.Math.abs;

like image 142
Goran Jovic Avatar answered Sep 20 '22 01:09

Goran Jovic