Automatic Import
Home ] Up ] Qualified Names ] The import Statement ] [ Automatic Import ] The package Statement ] Compilation Units ] Host Support for Packages ] Type Definitions ] Access Control ]

 

 

Package java.lang

The following import statement is implicit in every Java program:

import java.lang.*; // import all classes in java.lang

so, you never have to add that particular import statement to your program source.

The following public types are defined in java.lang (this is not a complete list, and is subject to augmentation in every release of Java):

AbstractMethodError
ArithmeticException
ArrayStoreException
Boolean
Character
Class
ClassCastException
ClassCircularityError
ClassFormatError
ClassLoader
ClassNotFoundException
CloneNotSupportedException
Cloneable
Compiler
Double
Error
Exception
ExceptionInInitializerError
Float
IllegalAccessError
IllegalAccessException
IllegalArgumentException
IllegalMonitorStateException
IllegalThreadStateException
IncompatibleClassChangeError
IndexOutOfBoundsException
InstantiationError
InstantiationException
Integer
InternalError
InterruptedException
LinkageError
Long
Math
NegativeArraySizeException
NoClassDefFoundError
NoSuchFieldError
NoSuchMethodError
NullPointerException
Number
NumberFormatException
Object
OutOfMemoryError
Process
Runnable
Runtime
RuntimeException
SecurityException
SecurityManager
StackOverflowError
String
StringBuffer
System
Thread
ThreadDeath
ThreadGroup
Throwable
UnknownError
UnsatisfiedLinkError
VerifyError
VirtualMachineError

The Default Package

Another package that is implicitly and automatically imported in every Java program is the default package.  The default package is the package which contains every Java class that does not have an explicit package definition.

Note: I strongly discourage the use of the default package for other than truly trivial (i.e. not intended for any serious application) Java code.

The Current Package

Finally, one more package which is automatically imported is the package specified for the current Java class.

In other words, if you place your class Fontleroy into the little.lord package, then, when the Java compiler compiles your class, it implicitly does the following import:

import little.lord.*;
 

This page was last modified on 02 October, 2007