Reputation: 479
I know that String, Integer and Double are standard classes of Java, but would Math fall into this category?
You definitely do not have to import it like the Scanner class, which isn't a standard class of Java.
Perhaps I do not understand what a standard class is. Can someone explain this for me?
Upvotes: 0
Views: 4139
Reputation: 71
yes Math class i standard, Math package is imported by default.
java.lang.Math
class is part of java.lang
class which are imported by default.
Go to this link if you want to learn about everything include in java.lang
package http://docs.oracle.com/javase/7/docs/api/java/lang/package-summary.html
Upvotes: -1
Reputation: 121860
would Math fall into this category?
Yes. It is documented as part of the JDK javadoc (since JDK 1.0) so you are guaranteed that it will exist in any JRE you'll ever encounter.
Note that since it resides in java.lang
, you do not have to import
it explicitly; you could:
import java.lang.Math;
but since all classes in java.lang
are automatically imported (that includes String
and Integer
for instance), you need not do that.
This is a peculiar class in the sense that it cannot be instantiated and it only contains static methods and constants; apart from that you are sure to have it available, and that methods and constants obey the defined contract.
Upvotes: 6
Reputation: 7870
It comes with the SDK, if that is what "standard" meant.
It is part of the java.lang package, thus does not require import.
Upvotes: 1