Download Java Packages

yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Java Packages
CSci 1130
Intro to Computer Programming
with Java
Instructor Tatyana Volk
Java is a relatively simple language,
but it has a set of standard packages
which can be used by any of the
program. A package is a collection of
classes which logically fit together
and which may interact between
Sun Microsystem provides a version of
two of those programs together , together
with some other useful programs, in Java
Development Kit (JDK).
Important resource provided by JDK is
Application Programming Interface (API),
which gives details of all the classes
provided by Sun Microsystems for Java
Packages are used to group related classes for use
in other programs. There are several class
packages that come with Java.
By default, every Java application imports the
classes contained within the java.lang package ,
so you do not have to manually import this
Java Packages
applet - for creating Java applet to run on the Web
awt -for graphics and and graphical user
io - for input and output
lang - for routine language functions
net - for networking
util - for additional utilities
Accessing a package:
java.package.* ;
Appendix O contains a summary of
the Java application Programming
Interface (API), version 1.1
Note: class System is a part of
java.lang (does not need import
Note: using import statement to include packages
is similar to using the include statement in C.
The * character in import statement tells the
Java compiler to use all the classes stored within
the package. You could also specify which
classes to use, but because you are usually need
many classes within the single package it is
easier to use the asterisk.
Also Java compiler understands which classes
are used and which are not, so using the asterisk
does not eat up any additional memory.
We can use several individual imports, one for each
For example, Date and Random are classes in the
java.util package.
We can say
import java.util.Date ;
import java.util.Random;
import java.util.* ;
the effect will be the same.