Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Packages CSci 1130 Intro to Computer Programming with Java Instructor Tatyana Volk.

Similar presentations


Presentation on theme: "Java Packages CSci 1130 Intro to Computer Programming with Java Instructor Tatyana Volk."— Presentation transcript:

1 Java Packages CSci 1130 Intro to Computer Programming with Java Instructor Tatyana Volk

2 Packages. 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 themselves.

3 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 language.

4 Package import java.applet.*; import java.awt.*; 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 package.

5 applet - for creating Java applet to run on the Web awt -for graphics and and graphical user interfacing io - for input and output lang - for routine language functions net - for networking util - for additional utilities Java Packages

6 Accessing a package: import java.package.* ;

7 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 statement)

8 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.

9 We can use several individual imports, one for each class. For example, Date and Random are classes in the java.util package. We can say import java.util.Date ; import java.util.Random; or import java.util.* ; the effect will be the same.


Download ppt "Java Packages CSci 1130 Intro to Computer Programming with Java Instructor Tatyana Volk."

Similar presentations


Ads by Google