how to import math?
im using jdk 5.0
how to use or import the PI or square root method/class into my class?
let's say for example
import static java.lang.Math.PI;
import static java.lang.Math.sqrt;
this two lines are all working..but according to the documention
in JDK 5.0 math is automatically imported to java.lang...
..
what are the the other method's or shortcut to use that PI or sqrt?
let's say for example a problem is looking for the circumference of a circle
or a radius.. so we will need the PI and sqrt methods right?..so thats the question.."shortcuts on how to import those two stuffs"..
[652 byte] By [
nemo666a] at [2007-11-27 11:45:35]

The Math class is in the lang package which is implicitly imported. There is no need for you to import the package. If oyu want to use the Math class then do so. Since PI is static you access it statically:
double value = someValue * Math.PI;
You can write this:// import *all* the static stuff from java.lang.Math
import static java.lang.Math.*;
public class MathEg {
public static void main(String args[]) {
System.out.println(PI);
System.out.println(sqrt(PI));
}
}
But I find Math.PI, Math.sqrt() easier to read and less liable to problems if I decide to implement, say, another sqrt() method that handles NaN differently.
[Edit] Or if I use static things from lots of classes - import static some.package.* doesn't make it clear what comes from where.