1 / 9

Java Packages

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

Download Presentation

Java Packages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Java Packages 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

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

  7. Appendix O contains a summary of the Java application Programming Interface (API), version 1.1 Note:classSystemis a part ofjava.lang (does not needimportstatement)

  8. Note: using import statement to include packages is similar to using the include statement in C. The * character in importstatement 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.

More Related