Why won't abs() in java work?

I have always had a question about java.lang.Math: (It might by very basic)

Why do I have to Math.abs(-100) and can't to abs(-100)?

I figure that Math is a class. And abs is a static method. But why can I not simply import java.lang.Math and use abs(-100)?

Jon Skeet
people
quotationmark

You can import all the methods in Math:

import static java.lang.Math.*;

or just the one method you want:

import static java.lang.Math.abs;

Normal imports just import classes, making that class available via its short name.

people

See more on this question at Stackoverflow