Creating your own packages Assignment Help

Assignment Help: >> Packages in Java >> Creating your own packages

Creating your own packages:

So far you have seen how packages are provided as part of the Java class library. It is perfectly possible for you to create your own packages, which is especially useful in organizing your work on large projects. A package forms a compilation unit - that is, a group of source files that you can compile independently of other parts of the system. Where a considerable number of classes are developed for a large system, this avoids having to continually compile and recompile the whole system as development proceeds.

Packages are also significant in terms of the visibility of items such as methods and instance variables. If these items are not explicitly declared as private, public and so on, they default to package visibility - that is, they are accessible to all classes in the same package.

To define a collection of classes as a package, you need to precede the source code of each of the classes with the keyword package followed by the name of the package, as follows:

package telNetCommsPackage;

Package names sometimes have several components, separated by a dot, to refiect the hierarchical organization of packages. For example:

package general.utilities;
package javax.swing;

Each component of the package name typically corresponds to a subdirectory within the base directory for this project or the base directory for Java libraries, as appropriate. The example later in this section explains this in more detail.

However, this correspondence between package name and directory structure is not mandated by the language specification and may vary between different Java systems.

Relationships can be defined between groups of packages. Packages can have subpackages. For example, java.awt has many subpackages such as java.awt.event and java.awt.image. However, the term subpackage may be a little misleading. Each of these three packages contains a number of classes and other items useful for building basic GUIs. The important point is that their contents are distinct from one another. For example, java.awt does not contain java.awt.event; if you want classes from both of these packages then you must explicitly import from both, as follows:

import java.awt.*;
import java.awt.event.*;

The subpackages of java.awt are named in this way to make clear that they depend on java.awt.

If you omit a package declaration, the Java system will assume your classes are in an 'unnamed package', which typically consists of all the Java source files residing in the current directory for Java source files. This works well enough for small, experimental programs, but larger programs should be explicitly structured into packages to benefit from the advantages outlined above.

 

Java Assignment Help - Java Homework Help

Struggling with java programming language? Are you not finding solution for your Creating your own packages homework and assignments? Live Creating your own packages experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Creating your own packages homework help, java assignment help and Creating your own packages projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.

Why Expertsmind for assignment help

  1. Higher degree holder and experienced experts network
  2. Punctuality and responsibility of work
  3. Quality solution with 100% plagiarism free answers
  4. Time on Delivery
  5. Privacy of information and details
  6. Excellence in solving java programming language queries in excels and word format.
  7. Best tutoring assistance 24x7 hours

 

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd