File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes abs() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "abs()" Watch "abs()" New topic



Joined: Feb 18, 2000
Posts: 10
I am getting the error' Method abs() not found' error . when I compile the following code.
Please explain me why???
import java.lang.Math;
public class Testexam {
public static void main (String args []) {
double d = 12.56;

Thandapani Saravanan
Ranch Hand

Joined: Oct 17, 1999
Posts: 117
I think you must tell the compiler which class the method belongs to. Here it is Math and Math.abs(d) is how you call abs.
You don't have to import java.lang.Math here, it is done for you.

Tony Alicea

Joined: Jan 30, 2000
Posts: 3226
For static methods you need to include the name of the class.
Also, the <CODE>java.lang</CODE> package is automatically included in every Java program.

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
I agree. Here's the link:
subject: abs()
jQuery in Action, 3rd edition