100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Lecture notes

Working with Packages and Using Javadoc to document a Package

Rating
-
Sold
-
Pages
11
Uploaded on
16-06-2021
Written in
2020/2021

Packages provide two main advantages. First, when a project contains a large number of classes, packages can provide some logical structure to your application and make it easier to find the classes that your are looking for. Secondly, packages provide a way to avoid naming conflicts between classes. This is particularly important if you want to make your classes avaibable to other programmers.

Show more Read less
Institution
Module









Whoops! We can’t load your doc right now. Try again or contact support.

Connected book

Written for

Institution
Module

Document information

Uploaded on
June 16, 2021
Number of pages
11
Written in
2020/2021
Type
Lecture notes
Professor(s)
Dr simba
Contains
All classes

Subjects

Content preview

CSI21M1 Java Programming Notes, prepared by Mr. S. Nyika, Semester I, 2019


Lecture 4: Working with Packages and Using Javadoc to document a Package

Objectives:
At the end of this lecture, students will be able to:
• explain the idea of a package
• create a new package
• add a class to a package
• delete a package
• rename a package
• move a class from one package to another
• navigate existing packages
• understand documentation using javadoc
• create a library for a package
• use a library in an application

Notes:

To make it easy to find and access classes, the Java API organizes its classes into packages. This allows
you to import just the classes and packages that an application needs.

Packages provide two main advantages. First, when a project contains a large number of classes,
packages can provide some logical structure to your application and make it easier to find the classes
that your are looking for. Secondly, packages provide a way to avoid naming conflicts between classes.
This is particularly important if you want to make your classes avaibable to other programmers.

The following shows the directories and files of the StudenApp application




Page 1 of 11

, CSI21M1 Java Programming Notes, prepared by Mr. S. Nyika, Semester I, 2019



Here the project folder, StudentSofware, which has the following directory hierararchy:




contains the subdirectories for each package. Then, each subdirectory contains the classes which define
the business objects for this application.

When you name a package, you can use any name you want. However, if you want to make sure
that the name of your package is unique, its considered a good practice to start the name of your
internet domain name in reverse. For example za.ac.wsu.snyika, so all my classes would be stored
in this package. Even if you do not follow this convention, you should avoid using a general name, for
example a package name snyika would be too general.

Once you store a class in the correct directory, you must code a package statement at the beginning of
the class. This statement consists of the package keyword followed by the name of the package. For
example as shown earlier, the statement in the Student class is package za.ac.wsu.snyika. This
statement will make sure that the folders are created when your program is compiled.

If a class is stored in a package, it cannot be accessed from classes in other packages without qualifying
it with the name of the package. As a result, you typically import the class to make it easier to refer
to. This works the same for the packages and classes that your create as it does for the classes of the
Java API such as JoptionPane.




Page 2 of 11
$3.10
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
keanuperumal

Get to know the seller

Seller avatar
keanuperumal Walter Sisulu University
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
4 year
Number of followers
1
Documents
10
Last sold
4 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions